summaryrefslogtreecommitdiffstats
path: root/contrib/gcc/cpplib.c
diff options
context:
space:
mode:
authorkan <kan@FreeBSD.org>2002-10-10 04:40:18 +0000
committerkan <kan@FreeBSD.org>2002-10-10 04:40:18 +0000
commit92318bc515d223b2eeebb665f76e131dd2318b2b (patch)
treef505e08c93c8d3d8e51f5dac050b459cce4d4ae2 /contrib/gcc/cpplib.c
parent48f00f4c43af857e09b5f961c806a8811c504a3c (diff)
downloadFreeBSD-src-92318bc515d223b2eeebb665f76e131dd2318b2b.zip
FreeBSD-src-92318bc515d223b2eeebb665f76e131dd2318b2b.tar.gz
Gcc 3.2.1-prerelease from the FSF anoncvs repo gcc-3_2-branch on October 9th 2002 20:15 EST.
Diffstat (limited to 'contrib/gcc/cpplib.c')
-rw-r--r--contrib/gcc/cpplib.c57
1 files changed, 39 insertions, 18 deletions
diff --git a/contrib/gcc/cpplib.c b/contrib/gcc/cpplib.c
index 096a711..cff9eeb 100644
--- a/contrib/gcc/cpplib.c
+++ b/contrib/gcc/cpplib.c
@@ -1224,6 +1224,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;)
@@ -1235,7 +1238,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. */
@@ -1245,25 +1281,10 @@ _cpp_do__Pragma (pfile)
{
const cpp_token *string = get__Pragma_string (pfile);
- if (!string)
- cpp_error (pfile, "_Pragma takes a parenthesized string literal");
+ if (string)
+ destringize_and_run (pfile, &string->val.str);
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;
- }
+ cpp_error (pfile, "_Pragma takes a parenthesized string literal");
}
/* Just ignore #sccs, on systems where we define it at all. */
OpenPOWER on IntegriCloud