This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
cpplib: Fix PR preprocessor/6780
- From: Neil Booth <neil at daikokuya dot demon dot co dot uk>
- To: gcc-patches at gcc dot gnu dot org
- Cc: loewis at informatik dot hu-berlin dot de
- Date: Fri, 24 May 2002 20:16:59 +0100
- Subject: cpplib: Fix PR preprocessor/6780
For
#define inc2(a,b) <##a##.##b##>
#define INC(X) inc2(X,h)
#include INC(stdio)
we used to give the bogus messages
/tmp/foo.c:3:18: missing terminating > character
/tmp/foo.c:3:18: pasting "<stdio>" and "." does not give a valid
preprocessing token
and not include the header. With this patch we output the accurate
/tmp/foo.c:3:18: warning: pasting "<" and "stdio" does not give a valid
preprocessing token
/tmp/foo.c:3:18: warning: pasting "stdio" and "." does not give a valid
preprocessing token
/tmp/foo.c:3:18: warning: pasting "." and "h" does not give a valid
preprocessing token
/tmp/foo.c:3:18: warning: pasting "h" and ">" does not give a valid
preprocessing token
and include the header. I'm applying this to 3.1 and 3.2.
Neil.
PR preprocessor/6780
* cppmacro.c (enter_macro_context): Clear state.angled_headers.
testsuite:
* gcc.dg/cpp/paste12.c: New test.
Index: cppmacro.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppmacro.c,v
retrieving revision 1.106
diff -u -p -r1.106 cppmacro.c
--- cppmacro.c 22 May 2002 22:02:15 -0000 1.106
+++ cppmacro.c 24 May 2002 09:28:12 -0000
@@ -660,6 +660,8 @@ enter_macro_context (pfile, node)
/* The presence of a macro invalidates a file's controlling macro. */
pfile->mi_valid = false;
+ pfile->state.angled_headers = false;
+
/* Handle standard macros. */
if (! (node->flags & NODE_BUILTIN))
{
Index: testsuite/gcc.dg/cpp/paste12.c
===================================================================
RCS file: testsuite/gcc.dg/cpp/paste12.c
diff -N testsuite/gcc.dg/cpp/paste12.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/cpp/paste12.c 24 May 2002 09:28:12 -0000
@@ -0,0 +1,8 @@
+/* { dg-do preprocess } */
+
+/* Test correct diagnostics when pasting in #include.
+ Source: PR preprocessor/6780. */
+
+#define inc2(a,b) <##a.b>
+#define INC(X) inc2(X,h)
+#include INC(stdio) /* { dg-error "pasting \"<\" and \"stdio\" does not" } */