This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
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 18:58:12 +0100
- Subject: 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>
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")