diff options
author | Neil Booth <neil@daikokuya.co.uk> | 2002-09-03 21:55:40 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2002-09-03 21:55:40 +0000 |
commit | 79ba5e3b9e7f922a99c698829c88f2b47700fd5e (patch) | |
tree | 84d9fd1cdaf53611a6a00b419c9f785e32787d39 | |
parent | f4701961145138742997ead9600196211450c9d9 (diff) | |
download | gcc-79ba5e3b9e7f922a99c698829c88f2b47700fd5e.zip gcc-79ba5e3b9e7f922a99c698829c88f2b47700fd5e.tar.gz gcc-79ba5e3b9e7f922a99c698829c88f2b47700fd5e.tar.bz2 |
Debian BTS Bug #
Debian BTS Bug #
* cpphash.h (FIRST, LAST, CUR, RLIMIT): Fix definitions.
* cpplib.c (destringize_and_run): Kludge around getting
tokens from in-progress macros.
(_cpp_do__Pragma): Simplify.
testsuite:
* gcc.dg/cpp/_Pragma4.c: New test.
From-SVN: r56773
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cpphash.h | 8 | ||||
-rw-r--r-- | gcc/cpplib.c | 57 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/_Pragma4.c | 12 |
5 files changed, 67 insertions, 22 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5b94861..8f88554 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2002-09-03 Neil Booth <neil@daikokuya.co.uk> + + Debian BTS Bug #157416 + * cpphash.h (FIRST, LAST, CUR, RLIMIT): Fix definitions. + * cpplib.c (destringize_and_run): Kludge around getting + tokens from in-progress macros. + (_cpp_do__Pragma): Simplify. + 2002-09-03 Steve Ellcey <sje@cup.hp.com> * config/ia64/ia64.h (EXTRA_SPECS): Remove cpp_cpu. diff --git a/gcc/cpphash.h b/gcc/cpphash.h index 5b0f0e8..61027f2 100644 --- a/gcc/cpphash.h +++ b/gcc/cpphash.h @@ -166,10 +166,10 @@ struct tokenrun }; /* Accessor macros for struct cpp_context. */ -#define FIRST(c) (c->u.iso.first) -#define LAST(c) (c->u.iso.last) -#define CUR(c) (c->u.trad.cur) -#define RLIMIT(c) (c->u.trad.rlimit) +#define FIRST(c) ((c)->u.iso.first) +#define LAST(c) ((c)->u.iso.last) +#define CUR(c) ((c)->u.trad.cur) +#define RLIMIT(c) ((c)->u.trad.rlimit) typedef struct cpp_context cpp_context; struct cpp_context diff --git a/gcc/cpplib.c b/gcc/cpplib.c index 0e9c4a1..ef167f2 100644 --- a/gcc/cpplib.c +++ b/gcc/cpplib.c @@ -1277,6 +1277,9 @@ 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;) @@ -1288,7 +1291,40 @@ 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. + + 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; + + /* See above comment. For the moment, we'd like + + token1 _Pragma ("foo") token2 + + to be output as + + token1 + # 7 "file.c" + #pragma foo + # 7 "file.c" + token2 + + Getting the line markers is a little tricky. */ + if (pfile->cb.line_change) + (*pfile->cb.line_change) (pfile, pfile->cur_token, false); } /* Handle the _Pragma operator. */ @@ -1298,26 +1334,11 @@ _cpp_do__Pragma (pfile) { const cpp_token *string = get__Pragma_string (pfile); - if (!string) + if (string) + destringize_and_run (pfile, &string->val.str); + else cpp_error (pfile, DL_ERROR, "_Pragma takes a parenthesized string literal"); - else - { - /* Ideally, we'd like - token1 _Pragma ("foo") token2 - to be output as - token1 - # 7 "file.c" - #pragma foo - # 7 "file.c" - token2 - Getting these correct line markers is a little tricky. */ - - unsigned int orig_line = pfile->line; - destringize_and_run (pfile, &string->val.str); - pfile->line = orig_line; - pfile->buffer->saved_flags = BOL; - } } /* Just ignore #sccs on all systems. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 78dc124..b1f4655 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2002-09-03 Neil Booth <neil@daikokuya.co.uk> + + * gcc.dg/cpp/_Pragma4.c: New test. + Tue Sep 3 11:04:26 2002 Nicola Pero <n.pero@mi.flashnet.it> * objc/execute/nil_method-1.m: New testcase. diff --git a/gcc/testsuite/gcc.dg/cpp/_Pragma4.c b/gcc/testsuite/gcc.dg/cpp/_Pragma4.c new file mode 100644 index 0000000..8d8cea5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/_Pragma4.c @@ -0,0 +1,12 @@ +/* { dg-do preprocess } */ + +/* Based on Debian GNATS PR 157416. 3 Sep 2002. */ + +#define b foo _Pragma ("bar") baz +a b c + +/* + { dg-final { if ![file exists _Pragma4.i] { return } } } + { dg-final { if { [grep _Pragma4.i "#pragma bat "] != "" } { return } } } + { dg-final { fail "_Pragma4.c: #pragma appearing on its own line" } } +*/ |