* Fix preprocessor/7526
[not found] ` <3D5A7B0D.6010405@demig.de>
@ 2002-08-14 10:58 ` Neil Booth
2002-08-14 11:05 ` Neil Booth
0 siblings, 1 reply; 2+ messages in thread
From: Neil Booth @ 2002-08-14 10:58 UTC (permalink / raw)
To: Norbert Koch; +Cc: gcc-patches
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")
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Fix preprocessor/7526
2002-08-14 10:58 ` Fix preprocessor/7526 Neil Booth
@ 2002-08-14 11:05 ` Neil Booth
0 siblings, 0 replies; 2+ messages in thread
From: Neil Booth @ 2002-08-14 11:05 UTC (permalink / raw)
To: Norbert Koch; +Cc: gcc-patches
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")
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-08-14 18:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20020813105905.25244.qmail@sources.redhat.com>
[not found] ` <3D591E49.5000306@demig.de>
[not found] ` <20020813163750.GA29906@daikokuya.co.uk>
[not found] ` <3D59FBC0.9020308@demig.de>
[not found] ` <20020814070055.GA4939@daikokuya.co.uk>
[not found] ` <3D5A7B0D.6010405@demig.de>
2002-08-14 10:58 ` Fix preprocessor/7526 Neil Booth
2002-08-14 11:05 ` Neil Booth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).