This is the mail archive of the gcc-bugs@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: Fix preprocessor/7150


Jason R Thorpe wrote:-

> Yes, the segv is gone.  But it still doesn't work properly :-)
> 
> I've attached some files as an example of the failure.
> 
> 	x86_64-unknown-netbsd-gcc -traditional-cpp -M \
> 	    -D_LOCORE -Dx86_64 -D_KERNEL microtime.S
> 
> In file included from microtime.S:36:
> asm.h:71: unterminated #ifdef
> asm.h:64: unterminated #ifndef
> asm.h:41: unterminated #ifndef
> 
> Also attached is the output of:
> 
> 	x86_64-unknown-netbsd-gcc -traditional-cpp -E \
> 	    -D_LOCORE -Dx86_64 -D_KERNEL microtime.S
> 
> Look for "SHOULD NOT BE HERE" and "NEITHER SHOULD THIS".  Also note that
> the _ENTRY() macro (used by ENTRY()) from asm.h does not get expanded.

Thanks for the feedback.  I can't reproduce your -M issue with
unterminated #ifdefs.  Let me know if it is still there for you.
[I've just noticed I omitted to commit cppmacro.c in my previous patch.
I've applied it now; I think that may be what fixes this.]

I believe the last two issues are fixed with this patch and testcase,
which I've applied as obvious.  Let me know how things look for you
now.

Thanks,

Neil.

	* cpptrad.c (skip_whitespace): Pass pointer to prior char.
testsuite:
	* gcc.dg/cpp/trad/escaped-nl.c: New test.

Index: cpptrad.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpptrad.c,v
retrieving revision 1.22
diff -u -p -r1.22 cpptrad.c
--- cpptrad.c	28 Jun 2002 06:26:54 -0000	1.22
+++ cpptrad.c	1 Jul 2002 12:48:02 -0000
@@ -284,7 +284,7 @@ skip_whitespace (pfile, cur, skip_commen
       out--;
       if (c == '\\' && is_vspace (*cur))
 	{
-	  cur = skip_escaped_newlines (pfile, cur);
+	  cur = skip_escaped_newlines (pfile, cur - 1);
 	  continue;
 	}
 
Index: testsuite//gcc.dg/cpp/trad/escaped-nl.c
===================================================================
RCS file: testsuite//gcc.dg/cpp/trad/escaped-nl.c
diff -N testsuite//gcc.dg/cpp/trad/escaped-nl.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite//gcc.dg/cpp/trad/escaped-nl.c	1 Jul 2002 12:48:03 -0000
@@ -0,0 +1,10 @@
+/* Test escaped newlines at start of macro definition are properly
+   skipped (buglet in skip_whitespace () in cpptrad.c).  */
+
+/* { dg-do preprocess } */
+
+#define NUM \
+100
+#if NUM != 100
+# error NUM not defined properly /* { dg-bogus "error" } */
+#endif


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