This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix -traditional-cpp preprocessing (PR preprocessor/39213)


> 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.


-- 
Eric Botcazou
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);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]