re PR preprocessor/8524 (_Pragma within macros is improperly expanded)
PR preprocessor/8524 * cpplib.c (run_directive): Remove previous kludge to _Pragma. Add a new one in its place, which hopefully works. (skip_rest_of_line): Change test for bottom-of-context-stack. testsuite: * gcc.dg/cpp/_Pragma5.c: New test. From-SVN: r59232
This commit is contained in:
parent
9519920205
commit
8128cccfcf
4 changed files with 48 additions and 21 deletions
|
@ -1,3 +1,10 @@
|
|||
2002-11-18 Neil Booth <neil@daikokuya.co.uk>
|
||||
|
||||
PR preprocessor/8524
|
||||
* cpplib.c (run_directive): Remove previous kludge to _Pragma.
|
||||
Add a new one in its place, which hopefully works.
|
||||
(skip_rest_of_line): Change test for bottom-of-context-stack.
|
||||
|
||||
Mon Nov 18 21:29:03 CET 2002 Jan Hubicka <jh@suse.cz>
|
||||
|
||||
* i386.md (addqi_1_slp): Fix output template.
|
||||
|
|
44
gcc/cpplib.c
44
gcc/cpplib.c
|
@ -207,7 +207,7 @@ skip_rest_of_line (pfile)
|
|||
cpp_reader *pfile;
|
||||
{
|
||||
/* Discard all stacked contexts. */
|
||||
while (pfile->context != &pfile->base_context)
|
||||
while (pfile->context->prev)
|
||||
_cpp_pop_context (pfile);
|
||||
|
||||
/* Sweep up all tokens remaining on the line. */
|
||||
|
@ -1277,9 +1277,6 @@ destringize_and_run (pfile, in)
|
|||
{
|
||||
const unsigned char *src, *limit;
|
||||
char *dest, *result;
|
||||
cpp_context saved_context;
|
||||
cpp_context *saved_cur_context;
|
||||
unsigned int saved_line;
|
||||
|
||||
dest = result = alloca (in->len + 1);
|
||||
for (src = in->text, limit = src + in->len; src < limit;)
|
||||
|
@ -1291,24 +1288,29 @@ destringize_and_run (pfile, in)
|
|||
}
|
||||
*dest = '\0';
|
||||
|
||||
/* FIXME. All this saving is a horrible kludge to handle the case
|
||||
when we're in a macro expansion.
|
||||
/* Ugh; an awful kludge. We are really not set up to be lexing
|
||||
tokens when in the middle of a macro expansion. Use a new
|
||||
context to force cpp_get_token to lex, and so skip_rest_of_line
|
||||
doesn't go beyond the end of the text. Also, remember the
|
||||
current lexing position so we can return to it later.
|
||||
|
||||
A better strategy it to not convert _Pragma to #pragma if doing
|
||||
preprocessed output, but to just pass it through as-is, unless it
|
||||
is a CPP pragma in which case is should be processed normally.
|
||||
When compiling the preprocessed output the _Pragma should be
|
||||
handled. This will be become necessary when we move to
|
||||
line-at-a-time lexing since we will be macro-expanding the line
|
||||
before outputting / compiling it. */
|
||||
saved_line = pfile->line;
|
||||
saved_context = pfile->base_context;
|
||||
saved_cur_context = pfile->context;
|
||||
pfile->context = &pfile->base_context;
|
||||
run_directive (pfile, T_PRAGMA, result, dest - result);
|
||||
pfile->context = saved_cur_context;
|
||||
pfile->base_context = saved_context;
|
||||
pfile->line = saved_line;
|
||||
Something like line-at-a-time lexing should remove the need for
|
||||
this. */
|
||||
{
|
||||
cpp_context *saved_context = pfile->context;
|
||||
cpp_token *saved_cur_token = pfile->cur_token;
|
||||
tokenrun *saved_cur_run = pfile->cur_run;
|
||||
|
||||
pfile->context = xnew (cpp_context);
|
||||
pfile->context->macro = 0;
|
||||
pfile->context->prev = 0;
|
||||
run_directive (pfile, T_PRAGMA, result, dest - result);
|
||||
free (pfile->context);
|
||||
pfile->context = saved_context;
|
||||
pfile->cur_token = saved_cur_token;
|
||||
pfile->cur_run = saved_cur_run;
|
||||
pfile->line--;
|
||||
}
|
||||
|
||||
/* See above comment. For the moment, we'd like
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2002-11-18 Neil Booth <neil@daikokuya.co.uk>
|
||||
|
||||
* gcc.dg/cpp/_Pragma5.c: New test.
|
||||
|
||||
2002-11-18 Richard Sandiford <rsandifo@redhat.com>
|
||||
|
||||
* gcc.c-torture/execute/20021118-2.c: New test.
|
||||
|
|
14
gcc/testsuite/gcc.dg/cpp/_Pragma5.c
Normal file
14
gcc/testsuite/gcc.dg/cpp/_Pragma5.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* { dg-do preprocess } */
|
||||
|
||||
/* Based on Debian GNATS PR 8524. 17 Nov 2002. */
|
||||
|
||||
#define ALPHA(A) alpha_ ## A
|
||||
#define BETA(B) beta_ ## B
|
||||
#define GAMMA(C) _Pragma("moose") ALPHA(C) BETA(C)
|
||||
GAMMA(baz);
|
||||
|
||||
/*
|
||||
{ dg-final { if ![file exists _Pragma5.i] { return } } }
|
||||
{ dg-final { if { [grep _Pragma5.i "alpha_baz beta_baz;"] != "" } { return } } }
|
||||
{ dg-final { fail "_Pragma5.c: _Pragma in macro" } }
|
||||
*/
|
Loading…
Add table
Reference in a new issue