This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fix preprocessor/7526
- From: Neil Booth <neil at daikokuya dot co dot uk>
- To: Norbert Koch <nkoch at demig dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 14 Aug 2002 19:05:45 +0100
- Subject: Re: Fix preprocessor/7526
- References: <20020813105905.25244.qmail@sources.redhat.com> <3D591E49.5000306@demig.de> <20020813163750.GA29906@daikokuya.co.uk> <3D59FBC0.9020308@demig.de> <20020814070055.GA4939@daikokuya.co.uk> <3D5A7B0D.6010405@demig.de> <20020814175812.GA10029@daikokuya.co.uk>
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")