diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-01-04 16:33:38 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-01-04 16:33:38 +0000 |
commit | b75b98aa8366f8c69c546a6e0a8f0e7559540363 (patch) | |
tree | 665a7e61be294c2530782e0d9fbb6a33d6ef62ea /libcpp/macro.c | |
parent | dbdaaad01d866c0620f69b9b78b8dadef5425e54 (diff) | |
download | gcc-b75b98aa8366f8c69c546a6e0a8f0e7559540363.tar.gz |
libcpp/
* directives.c (struct pragma_entry): Add is_deferred. Add ident
entry to value union.
(end_directive): Don't eat the line if in_deferred_pragma.
(run_directive): Remove pragma hacks.
(insert_pragma_entry): Remove.
(new_pragma_entry): New.
(register_pragma_1): Split out of register_pragma. Only handle
the lookup tree and return the new entry.
(cpp_register_pragma): Fill in the pragma entry here.
(cpp_register_deferred_pragma): New.
(register_pragma_internal): New.
(_cpp_init_internal_pragmas): Use register_pragma_internal.
(do_pragma): Allow pragma expansion after namespace. For deferred
pragmas, don't slurp the line into a string.
(destringize_and_run): Save tokens for deferred pragmas.
(cpp_handle_deferred_pragma): Remove.
* macro.c (builtin_macro): Remove pragma token hack.
(_cpp_push_token_context): Rename from push_token_context and export.
* internal.h (struct lexer_state): Add pragma_allow_expansion.
(_cpp_push_token_context): Declare.
* lex.c (_cpp_lex_token): Allow _cpp_handle_directive to return
a token. Update the line number correctly if so.
(_cpp_lex_direct): Emit CPP_PRAGMA_EOL tokens.
(cpp_token_val_index): Return CPP_TOKEN_FLD_PRAGMA for pragmas.
* include/cpplib.h (PRAGMA_EOL): New.
(CPP_TOKEN_FLD_PRAGMA): New.
(struct cpp_token): Add val.pragma.
(struct cpp_options): Remove defer_pragmas.
(cpp_handle_deferred_pragma): Remove.
(cpp_register_deferred_pragma): Declare.
gcc/
* c-lex.c (c_lex_with_flags) <CPP_PRAGMA>: Smuggle pragma id
via integer constant.
(pragma_lex): Remove.
* c-pch.c (c_common_pch_pragma): Accept the name as an argument,
rather than parsing it.
* c-pragma.c (handle_pragma_weak, handle_pragma_redefine_extname,
handle_pragma_extern_prefix): Add %< %> quotes.
(registered_pragmas): New.
(c_register_pragma_1): New.
(c_register_pragma): Use it.
(c_register_pragma_with_expansion): Likewise.
(c_invoke_pragma_handler): New.
(init_pragma): Use cpp_register_deferred_pragma directly for
pch_preprocess.
* c-pragma.h (enum pragma_kind): New.
(pragma_handler): New.
(c_invoke_pragma_handler): Declare.
* c-common.c (c_parse_error): Pretty print CPP_PRAGMA and
CPP_PRAGMA_EOL.
* c-common.h (c_common_pch_pragma): Update decl.
* Makefile.in (c-parser.o): Update dependencies.
(GTFILES): Add c-pragma.h.
* c-parser.c (struct c_token): Add pragma_kind.
(struct c_parser): Add in_pragma.
(c_lex_one_token): Always initialize keyword and pragma_kind.
Extract data for CPP_PRAGMA.
(c_parser_peek_2nd_token): Deny CPP_PRAGMA_EOL.
(c_parser_consume_token): Don't allow CPP_PRAGMA unless errors.
Don't allow CPP_PRAGMA_EOL if in_pragma.
(c_parser_consume_pragma): New.
(c_parser_skip_until_found): Stop on CPP_PRAGMA_EOL.
(c_parser_skip_to_end_of_parameter): Likewise.
(c_parser_skip_to_end_of_block_or_statement): Likewise.
(c_parser_skip_to_pragma_eol): New.
(c_parser_external_declaration): Handle CPP_PRAGMA.
(c_parser_compound_statement_nostart): Likewise.
(c_parser_statement_after_labels): Likewise.
(c_parser_pragma): New.
(pragma_lex): Likewise.
(c_parser_pragma_pch_preprocess): New.
(c_parser_new): Merge into ...
(c_parse_file): ... here. Call c_parser_pragma_pch_preprocess.
gcc/cp/
* lex.c (handle_pragma_java_exceptions): Fix whitespace.
* parser.c (struct cp_token): Add pragma_kind.
(eof_token): Update to match.
(struct cp_lexer): Add in_pragma; rearrange next for better packing.
(cp_parser_initial_pragma): New.
(cp_lexer_new_main): Use it. Don't bother clearing
c_lex_return_raw_strings.
(cp_lexer_get_preprocessor_token): Always initialize keyword
and pragma_kind fields. Handle CPP_PRAGMA.
(cp_lexer_consume_token): Don't allow CPP_PRAGMA_EOL when
in_pragma is set.
(cp_lexer_handle_pragma): Remove. Update callers to cp_parser_pragma.
(cp_lexer_print_token) <CPP_PRAGMA>: Don't print as a string.
(cp_parser_skip_to_pragma_eol): New.
(cp_parser_error): Use it.
(cp_parser_skip_to_closing_parenthesis): Stop at CPP_PRAGMA_EOL;
rearrange with switch statement.
(cp_parser_skip_to_end_of_statement): Likewise.
(cp_parser_skip_to_end_of_block_or_statement): Likewise.
(cp_parser_skip_to_closing_brace): Likewise.
(cp_parser_skip_until_found): Likewise.
(cp_parser_statement): Add in_compound argument; update callers.
Use it to decide how to handle pragma parsing.
(cp_parser_labeled_statement): Add in_compound argument; pass
it on to cp_parser_statement.
(cp_parser_statement_seq_opt): Stop at CPP_PRAGMA_EOL.
(cp_parser_declaration_seq_opt): Likewise.
(cp_parser_parameter_declaration): Likewise.
(cp_parser_member_specification_opt): Likewise.
(cp_parser_function_definition_after_decl): Likewise.
(cp_parser_cache_group): Handle CPP_PRAGMA/CPP_PRAGMA_EOL pairs.
(cp_parser_pragma): New.
(pragma_lex): New.
gcc/testsuite/
* g++.dg/parse/pragma2.C: Update expected error lines.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@109336 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp/macro.c')
-rw-r--r-- | libcpp/macro.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/libcpp/macro.c b/libcpp/macro.c index a0aa93ea994..2f1a97497a1 100644 --- a/libcpp/macro.c +++ b/libcpp/macro.c @@ -42,8 +42,6 @@ struct macro_arg static int enter_macro_context (cpp_reader *, cpp_hashnode *); static int builtin_macro (cpp_reader *, cpp_hashnode *); -static void push_token_context (cpp_reader *, cpp_hashnode *, - const cpp_token *, unsigned int); static void push_ptoken_context (cpp_reader *, cpp_hashnode *, _cpp_buff *, const cpp_token **, unsigned int); static _cpp_buff *collect_args (cpp_reader *, const cpp_hashnode *); @@ -261,13 +259,6 @@ builtin_macro (cpp_reader *pfile, cpp_hashnode *node) return 0; _cpp_do__Pragma (pfile); - if (pfile->directive_result.type == CPP_PRAGMA) - { - cpp_token *tok = _cpp_temp_token (pfile); - *tok = pfile->directive_result; - push_token_context (pfile, NULL, tok, 1); - } - return 1; } @@ -282,7 +273,7 @@ builtin_macro (cpp_reader *pfile, cpp_hashnode *node) /* Set pfile->cur_token as required by _cpp_lex_direct. */ pfile->cur_token = _cpp_temp_token (pfile); - push_token_context (pfile, NULL, _cpp_lex_direct (pfile), 1); + _cpp_push_token_context (pfile, NULL, _cpp_lex_direct (pfile), 1); if (pfile->buffer->cur != pfile->buffer->rlimit) cpp_error (pfile, CPP_DL_ICE, "invalid built-in macro \"%s\"", NODE_NAME (node)); @@ -480,7 +471,7 @@ paste_all_tokens (cpp_reader *pfile, const cpp_token *lhs) while (rhs->flags & PASTE_LEFT); /* Put the resulting token in its own context. */ - push_token_context (pfile, NULL, lhs, 1); + _cpp_push_token_context (pfile, NULL, lhs, 1); } /* Returns TRUE if the number of arguments ARGC supplied in an @@ -694,7 +685,7 @@ funlike_invocation_p (cpp_reader *pfile, cpp_hashnode *node) too difficult. We re-insert it in its own context. */ _cpp_backup_tokens (pfile, 1); if (padding) - push_token_context (pfile, NULL, padding, 1); + _cpp_push_token_context (pfile, NULL, padding, 1); } return NULL; @@ -750,7 +741,7 @@ enter_macro_context (cpp_reader *pfile, cpp_hashnode *node) macro->used = 1; if (macro->paramc == 0) - push_token_context (pfile, node, macro->exp.tokens, macro->count); + _cpp_push_token_context (pfile, node, macro->exp.tokens, macro->count); return 1; } @@ -943,9 +934,9 @@ push_ptoken_context (cpp_reader *pfile, cpp_hashnode *macro, _cpp_buff *buff, } /* Push a list of tokens. */ -static void -push_token_context (cpp_reader *pfile, cpp_hashnode *macro, - const cpp_token *first, unsigned int count) +void +_cpp_push_token_context (cpp_reader *pfile, cpp_hashnode *macro, + const cpp_token *first, unsigned int count) { cpp_context *context = next_context (pfile); |