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]

Fix preprocessor/7526


This kludge + testcase fixes PR preprocessor/7526.  When I get cpplib
doing a token line at a time, this will die the death it deserves
(along with other nasties in cpplib).

I'll apply this once a bootstrap completes.

Neil.

	PR preprocessor/7526
	* cpplib.c (do_pragma_dependency): Kludge to work properly
	within _Pragma.
testsuite:
	* gcc.dg/cpp/_Pragma3.c: New test.

Index: cpplib.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplib.c,v
retrieving revision 1.320
diff -u -p -r1.320 cpplib.c
--- cpplib.c	23 Jul 2002 22:57:44 -0000	1.320
+++ cpplib.c	14 Aug 2002 17:55:22 -0000
@@ -1206,6 +1206,7 @@ static void
 do_pragma_dependency (pfile)
      cpp_reader *pfile;
 {
+  cpp_buffer *buffer;
   const cpp_token *header;
   int ordering;
 
@@ -1213,7 +1214,16 @@ do_pragma_dependency (pfile)
   if (!header)
     return;
 
+  /* Disgusting hack around the fact that _Pragma buffers have a NULL
+     "inc" (#pragma dependency; see PR 7526).  When we do tokens a
+     line at a time, this can die as _Pragma should pop the buffer
+     after lexing its text.  */
+  buffer = pfile->buffer;
+  if (!buffer->inc)
+    pfile->buffer = buffer->prev;
   ordering = _cpp_compare_file_date (pfile, header);
+  pfile->buffer = buffer;
+
   if (ordering < 0)
     cpp_error (pfile, DL_WARNING, "cannot find source %s",
 	       cpp_token_as_text (pfile, header));
Index: testsuite/gcc.dg/cpp/_Pragma3.c
===================================================================
RCS file: testsuite/gcc.dg/cpp/_Pragma3.c
diff -N testsuite/gcc.dg/cpp/_Pragma3.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/cpp/_Pragma3.c	14 Aug 2002 17:55:22 -0000
@@ -0,0 +1,11 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.  */
+
+/* { dg-do preprocess } */
+
+/* Pragma buffers have a NULL "inc" member, which we would dereference
+   when getting a file's date and time.
+
+   Based on PR 7526.  14 Aug 2002.  */
+
+#define GCC_PRAGMA(x) _Pragma (#x)
+GCC_PRAGMA(GCC dependency "mi1c.h")


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