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: Fix #line syntax checks (PR 39647)


On Sat, 18 Apr 2009, Chris Lattner wrote:

> 
> On Apr 18, 2009, at 8:29 AM, Joseph S. Myers wrote:
> 
> > This patch fixes PR 39647, a preprocessor bug where #line directives
> > failed to allow for macros expanding to nothing after the initial line
> > number and file name.
> > 
> > Bootstrapped with no regressions on x86_64-unknown-linux-gnu.  Applied
> > to mainline.
> 
> Does this patch permit:
> 
> #define EMPTY
> #include <limits.h> EMPTY
> #include "limits.h" EMPTY
> 
> ?  If not, I think that's a bug (at least in c99)

Thanks for pointing out this case, I've applied this followup patch to fix 
it as well.

libcpp:
2009-04-18  Joseph Myers  <joseph@codesourcery.com>

	* directives.c (parse_include): Pass true to check_eol.

gcc/testsuite:
2009-04-18  Joseph Myers  <joseph@codesourcery.com>

	* gcc.dg/cpp/include5.c: New test.

Index: libcpp/directives.c
===================================================================
--- libcpp/directives.c	(revision 146319)
+++ libcpp/directives.c	(working copy)
@@ -724,7 +724,7 @@ parse_include (cpp_reader *pfile, int *p
       /* This pragma allows extra tokens after the file name.  */
     }
   else if (buf == NULL || CPP_OPTION (pfile, discard_comments))
-    check_eol (pfile, false);
+    check_eol (pfile, true);
   else
     {
       /* If we are not discarding comments, then gather them while
Index: gcc/testsuite/gcc.dg/cpp/include5.c
===================================================================
--- gcc/testsuite/gcc.dg/cpp/include5.c	(revision 0)
+++ gcc/testsuite/gcc.dg/cpp/include5.c	(revision 0)
@@ -0,0 +1,9 @@
+/* Test #include directives with macros expanding to empty.  */
+
+#define EMPTY_OBJ
+#define EMPTY_FUNC()
+
+#include <stddef.h> EMPTY_OBJ
+#include <stddef.h> EMPTY_FUNC()
+#include "stddef.h" EMPTY_OBJ
+#include "stddef.h" EMPTY_FUNC()

-- 
Joseph S. Myers
joseph@codesourcery.com


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