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]

mandatory error for '#ifdef a b'



ISO C requires a diagnostic for

#ifdef foo bar

as it violates a syntax rule.

I'll commit after the test on sparc-sun-solaris2.5.1 completes.

-- 
- Geoffrey Keating <geoffk@geoffk.org>

===File ~/patches/cygnus/nortel-ifdefextra.patch============
2000-12-01  Geoffrey Keating  <geoffk@redhat.com>

	* cpplib.c (do_ifdef): Add check_eol() call.
	(do_ifndef): Likewise.

2000-12-01  Geoffrey Keating  <geoffk@redhat.com>

	* gcc.dg/cpp/if-6.c: New testcase.
	
Index: cpplib.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplib.c,v
retrieving revision 1.223
diff -u -p -r1.223 cpplib.c
--- cpplib.c	2000/11/27 08:00:03	1.223
+++ cpplib.c	2000/12/02 00:21:19
@@ -1221,6 +1221,9 @@ do_ifdef (pfile)
 
       if (node)
 	skip = node->type != NT_MACRO;
+
+      if (node)
+	check_eol (pfile);
     }
 
   push_conditional (pfile, skip, T_IFDEF, 0);
@@ -1238,6 +1241,9 @@ do_ifndef (pfile)
       node = lex_macro_node (pfile);
       if (node)
 	skip = node->type == NT_MACRO;
+
+      if (node)
+	check_eol (pfile);
     }
 
   push_conditional (pfile, skip, T_IFNDEF, node);
Index: testsuite/gcc.dg/cpp/if-6.c
===================================================================
RCS file: if-6.c
diff -N if-6.c
--- /dev/null	Tue May  5 13:32:27 1998
+++ if-6.c	Fri Dec  1 16:21:19 2000
@@ -0,0 +1,3 @@
+/* { dg-do preprocess } */
+#ifdef foo bar  /* { dg-error "extra tokens" "tokens after #ifdef" } */
+#endif
============================================================

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