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 preprocessor/7526


Neil Booth wrote:-

> 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.

I've changed my mind to this instead.

Neil.

	PR preprocessor/7526
	* cpplib.c (run_directive): Kludge so _Pragma dependency works.
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 18:03:37 -0000
@@ -459,6 +459,9 @@ run_directive (pfile, dir_no, buf, count
 {
   cpp_push_buffer (pfile, (const uchar *) buf, count,
 		   /* from_stage3 */ true, 1);
+  /* Disgusting hack.  */
+  if (dir_no == T_PRAGMA)
+    pfile->buffer->inc = pfile->buffer->prev->inc;
   start_directive (pfile);
   /* We don't want a leading # to be interpreted as a directive.  */
   pfile->buffer->saved_flags = 0;
@@ -467,6 +470,8 @@ run_directive (pfile, dir_no, buf, count
     prepare_directive_trad (pfile);
   (void) (*pfile->directive->handler) (pfile);
   end_directive (pfile, 1);
+  if (dir_no == T_PRAGMA)
+    pfile->buffer->inc = NULL;
   _cpp_pop_buffer (pfile);
 }
 
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 18:03:37 -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]