diff options
Diffstat (limited to 'libcpp/macro.c')
-rw-r--r-- | libcpp/macro.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/libcpp/macro.c b/libcpp/macro.c index cbb0b0e7159..31de4156c64 100644 --- a/libcpp/macro.c +++ b/libcpp/macro.c @@ -65,7 +65,7 @@ static bool create_iso_definition (cpp_reader *, cpp_macro *); static cpp_token *alloc_expansion_token (cpp_reader *, cpp_macro *); static cpp_token *lex_expansion_token (cpp_reader *, cpp_macro *); -static bool warn_of_redefinition (cpp_reader *, const cpp_hashnode *, +static bool warn_of_redefinition (cpp_reader *, cpp_hashnode *, const cpp_macro *); static bool parse_params (cpp_reader *, cpp_macro *); static void check_trad_stringification (cpp_reader *, const cpp_macro *, @@ -835,7 +835,9 @@ enter_macro_context (cpp_reader *pfile, cpp_hashnode *node, if ((node->flags & NODE_BUILTIN) && !(node->flags & NODE_USED)) { node->flags |= NODE_USED; - if (pfile->cb.used_define) + if ((!pfile->cb.user_builtin_macro + || !pfile->cb.user_builtin_macro (pfile, node)) + && pfile->cb.used_define) pfile->cb.used_define (pfile, pfile->directive_line, node); } @@ -1430,7 +1432,7 @@ _cpp_backup_tokens (cpp_reader *pfile, unsigned int count) /* Returns nonzero if a macro redefinition warning is required. */ static bool -warn_of_redefinition (cpp_reader *pfile, const cpp_hashnode *node, +warn_of_redefinition (cpp_reader *pfile, cpp_hashnode *node, const cpp_macro *macro2) { const cpp_macro *macro1; @@ -1442,7 +1444,11 @@ warn_of_redefinition (cpp_reader *pfile, const cpp_hashnode *node, /* Suppress warnings for builtins that lack the NODE_WARN flag. */ if (node->flags & NODE_BUILTIN) - return false; + { + if (!pfile->cb.user_builtin_macro + || !pfile->cb.user_builtin_macro (pfile, node)) + return false; + } /* Redefinitions of conditional (context-sensitive) macros, on the other hand, must be allowed silently. */ @@ -1982,19 +1988,26 @@ check_trad_stringification (cpp_reader *pfile, const cpp_macro *macro, Caller is expected to generate the "#define" bit if needed. The returned text is temporary, and automatically freed later. */ const unsigned char * -cpp_macro_definition (cpp_reader *pfile, const cpp_hashnode *node) +cpp_macro_definition (cpp_reader *pfile, cpp_hashnode *node) { unsigned int i, len; - const cpp_macro *macro = node->value.macro; + const cpp_macro *macro; unsigned char *buffer; if (node->type != NT_MACRO || (node->flags & NODE_BUILTIN)) { - cpp_error (pfile, CPP_DL_ICE, - "invalid hash type %d in cpp_macro_definition", node->type); - return 0; + if (node->type != NT_MACRO + || !pfile->cb.user_builtin_macro + || !pfile->cb.user_builtin_macro (pfile, node)) + { + cpp_error (pfile, CPP_DL_ICE, + "invalid hash type %d in cpp_macro_definition", + node->type); + return 0; + } } + macro = node->value.macro; /* Calculate length. */ len = NODE_LEN (node) + 2; /* ' ' and NUL. */ if (macro->fun_like) |