diff mbox

Fix -traditional-cpp preprocessing (PR preprocessor/39213)

Message ID 201012190838.35674.ebotcazou@adacore.com
State New
Headers show

Commit Message

Eric Botcazou Dec. 19, 2010, 7:38 a.m. UTC
> This patch adds the same test to traditional preprocessing.  I've
> bootstrapped/regtested it on x86_64-linux and i686-linux and tries to
> preprocess a couple of large files with -traditional-cpp without any
> difference, but I can't reproduce the original problem.  CCing
> Eric who has managed to reproduce it on Solaris.

As explained in the audit trail, the patch doesn't work because calls to 
_cpp_overlay_buffer and _cpp_remove_overlay are unbalanced in the presence of 
#pragma redefine_extname, so the attached hunk is also needed.  In fact, it 
is even sufficient to fix the problem, without the traditional.c hunk.

Tested on sparc64-sun-solaris2.9 and i586-suse-linux.  OK for mainline and 
4.5/4.4 branches?  If so, which version?


2010-12-19  Eric Botcazou  <ebotcazou@adacore.com>
            Jakub Jelinek  <jakub@redhat.com>

        PR preprocessor/39213
	* directives.c (end_directive): Call _cpp_remove_overlay for deferred
	pragmas as well in traditional mode.
        * traditional.c (_cpp_scan_out_logical_line): Don't call
        _cpp_process_line_notes if pfile->overlaid_buffer.

Comments

Tom Tromey Jan. 4, 2011, 6:17 p.m. UTC | #1
>>>>> "Eric" == Eric Botcazou <ebotcazou@adacore.com> writes:

Eric> As explained in the audit trail, the patch doesn't work because
Eric> calls to _cpp_overlay_buffer and _cpp_remove_overlay are
Eric> unbalanced in the presence of #pragma redefine_extname, so the
Eric> attached hunk is also needed.  In fact, it is even sufficient to
Eric> fix the problem, without the traditional.c hunk.

Eric> Tested on sparc64-sun-solaris2.9 and i586-suse-linux.  OK for
Eric> mainline and 4.5/4.4 branches?  If so, which version?

This is ok.  I think it is fine to commit the version without the
traditional.c change.

Tom
Jakub Jelinek Jan. 4, 2011, 6:29 p.m. UTC | #2
On Tue, Jan 04, 2011 at 11:17:35AM -0700, Tom Tromey wrote:
> >>>>> "Eric" == Eric Botcazou <ebotcazou@adacore.com> writes:
> 
> Eric> As explained in the audit trail, the patch doesn't work because
> Eric> calls to _cpp_overlay_buffer and _cpp_remove_overlay are
> Eric> unbalanced in the presence of #pragma redefine_extname, so the
> Eric> attached hunk is also needed.  In fact, it is even sufficient to
> Eric> fix the problem, without the traditional.c hunk.
> 
> Eric> Tested on sparc64-sun-solaris2.9 and i586-suse-linux.  OK for
> Eric> mainline and 4.5/4.4 branches?  If so, which version?
> 
> This is ok.  I think it is fine to commit the version without the
> traditional.c change.

Yeah, the traditional.c change was just a shot in the dark.

	Jakub
diff mbox

Patch

Index: directives.c
===================================================================
--- directives.c	(revision 167901)
+++ directives.c	(working copy)
@@ -281,16 +281,17 @@  start_directive (cpp_reader *pfile)
 static void
 end_directive (cpp_reader *pfile, int skip_line)
 {
-  if (pfile->state.in_deferred_pragma)
-    ;
-  else if (CPP_OPTION (pfile, traditional))
+  if (CPP_OPTION (pfile, traditional))
     {
       /* Revert change of prepare_directive_trad.  */
-      pfile->state.prevent_expansion--;
+      if (!pfile->state.in_deferred_pragma)
+	pfile->state.prevent_expansion--;
 
       if (pfile->directive != &dtable[T_DEFINE])
 	_cpp_remove_overlay (pfile);
     }
+  else if (pfile->state.in_deferred_pragma)
+    ;
   /* We don't skip for an assembler #.  */
   else if (skip_line)
     {
Index: traditional.c
===================================================================
--- traditional.c	(revision 167901)
+++ traditional.c	(working copy)
@@ -1,5 +1,5 @@ 
 /* CPP Library - traditional lexical analysis and macro expansion.
-   Copyright (C) 2002, 2004, 2005, 2007, 2008, 2009
+   Copyright (C) 2002, 2004, 2005, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
    Contributed by Neil Booth, May 2002
 
@@ -378,7 +378,8 @@  _cpp_scan_out_logical_line (cpp_reader *
   for (;;)
     {
       if (!context->prev
-	  && cur >= pfile->buffer->notes[pfile->buffer->cur_note].pos)
+	  && cur >= pfile->buffer->notes[pfile->buffer->cur_note].pos
+	  && !pfile->overlaid_buffer)
 	{
 	  pfile->buffer->cur = cur;
 	  _cpp_process_line_notes (pfile, false);