summaryrefslogtreecommitdiff
path: root/gcc/cppmacro.c
diff options
context:
space:
mode:
authorNeil Booth <neilb@earthling.net>2000-10-30 22:29:00 +0000
committerNeil Booth <neil@gcc.gnu.org>2000-10-30 22:29:00 +0000
commita5c3cccda43ddeaa0e90df75f74c230dea0ad579 (patch)
treeaea40a1085df8546a232c08b4db9f87353674441 /gcc/cppmacro.c
parentdbdaea4110d5c97ba1addef900516eea7846a2c0 (diff)
downloadgcc-a5c3cccda43ddeaa0e90df75f74c230dea0ad579.tar.gz
cppfiles.c (stack_include_file): Check for stacked contexts here.
* cppfiles.c (stack_include_file): Check for stacked contexts here. * cpphash.h (_cpp_do__Pragma): New prototype. * cppinit.c (cpp_reader_init): Add _Pragma keyword to hash table. * cpplex.c (skip_escaped_newlines): Only process trigraphs and escaped newlines if !(buffer->from_stage3). (_cpp_lex_token): Warn about missing newlines iff !buffer->from_stage3. * cpplib.c (get__Pragma_string, destringize, _cpp_do__Pragma): New functions. (run_directive): Set output_line for _Pragma to avoid line markers in output. Set from_stage3 and prevent macro expansion for _Pragma and command-line options. Check buffer exhaustion. (cpp_push_buffer): Don't check for stacked macro contexts, as this is perfectly legitimate for _Pragma. Move the check to stack_include_file instead. Set from_stage3 iff buffer is preprocessed input. * cpplib.h (struct cpp_buffer): Make warned_cplusplus_comments unsigned. New boolean from_stage3. (struct spec_nodes): Add n__Pragma. * cppmacro.c (enter_macro_context): Flip sense of return value. (_cpp_get_token): Handle _Pragma operator. From-SVN: r37147
Diffstat (limited to 'gcc/cppmacro.c')
-rw-r--r--gcc/cppmacro.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/gcc/cppmacro.c b/gcc/cppmacro.c
index 9bd8884956b..484ce037a55 100644
--- a/gcc/cppmacro.c
+++ b/gcc/cppmacro.c
@@ -689,7 +689,8 @@ funlike_invocation_p (pfile, node, list)
/* Push the context of a macro onto the context stack. TOKEN is the
macro name. If we can successfully start expanding the macro,
- TOKEN is replaced with the first token of the expansion. */
+ TOKEN is replaced with the first token of the expansion, and we
+ return non-zero. */
static int
enter_macro_context (pfile, token)
cpp_reader *pfile;
@@ -704,7 +705,7 @@ enter_macro_context (pfile, token)
if (macro->disabled)
{
token->flags |= NO_EXPAND;
- return 1;
+ return 0;
}
/* Save the position of the outermost macro invocation. */
@@ -718,7 +719,7 @@ enter_macro_context (pfile, token)
{
if (!pfile->context->prev)
unlock_pools (pfile);
- return 1;
+ return 0;
}
/* Now push its context. */
@@ -740,7 +741,7 @@ enter_macro_context (pfile, token)
/* Disable the macro within its expansion. */
macro->disabled = 1;
- return 0;
+ return 1;
}
/* Move to the next context. Create one if there is none. */
@@ -922,6 +923,7 @@ _cpp_get_token (pfile, token)
cpp_reader *pfile;
cpp_token *token;
{
+ next_token:
for (;;)
{
cpp_context *context = pfile->context;
@@ -959,22 +961,34 @@ _cpp_get_token (pfile, token)
if (token->flags & PASTE_LEFT)
paste_all_tokens (pfile, token);
- if (token->type != CPP_NAME
- || token->val.node->type != NT_MACRO
- || pfile->state.prevent_expansion
- || token->flags & NO_EXPAND)
+ if (token->type != CPP_NAME)
break;
- /* Macros, built-in or not, invalidate controlling macros. */
- pfile->mi_state = MI_FAILED;
-
- if (token->val.node->flags & NODE_BUILTIN)
+ /* Handle macros and the _Pragma operator. */
+ if (token->val.node->type == NT_MACRO
+ && !pfile->state.prevent_expansion
+ && !(token->flags & NO_EXPAND))
{
- builtin_macro (pfile, token);
- break;
+ /* Macros invalidate controlling macros. */
+ pfile->mi_state = MI_FAILED;
+
+ if (token->val.node->flags & NODE_BUILTIN)
+ {
+ builtin_macro (pfile, token);
+ break;
+ }
+
+ if (enter_macro_context (pfile, token))
+ continue;
}
- else if (enter_macro_context (pfile, token))
+
+ if (token->val.node != pfile->spec_nodes.n__Pragma)
break;
+
+ /* Invalidate controlling macros. */
+ pfile->mi_state = MI_FAILED;
+ _cpp_do__Pragma (pfile);
+ goto next_token;
}
}