From e9a2e208dd763bf71b0cc9db8526ef8f47ee289e Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Mon, 2 Nov 2020 08:29:58 -0800 Subject: cpplib: Macro use location and comparison Our macro use hook passes a location, but doesn't recieve it from the using location. This patch adds the extra location_t parameter and passes it though. A second cleanup is breaking out the macro comparison code from the redefinition warning. That;ll turn out useful for modules. Finally, there's a filename comparison needed for the location optimization of rewinding from line 2 (occurs during the emission of builtin macros). libcpp/ * internal.h (_cpp_notify_macro_use): Add location parm. (_cpp_maybe_notify_macro_use): Likewise. * directives.c (_cpp_do_file_change): Check we've not changed file when optimizing a rewind. (do_ifdef): Pass location to _cpp_maybe_notify_macro_use. (do_ifndef): Likewise. Delete obsolete comment about powerpc. * expr.c (parse_defined): Pass location to _cpp_maybe_notify_macro_use. * macro.c (enter_macro_context): Likewise. (warn_of_redefinition): Break out helper function. Call it. (compare_macros): New function broken out of warn_of_redefinition. (_cpp_new_macro): Zero all fields. (_cpp_notify_macro_use): Add location parameter. --- libcpp/internal.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libcpp/internal.h') diff --git a/libcpp/internal.h b/libcpp/internal.h index b1a2a99..4759961 100644 --- a/libcpp/internal.h +++ b/libcpp/internal.h @@ -649,11 +649,13 @@ inline bool _cpp_defined_macro_p (cpp_hashnode *node) } /* In macro.c */ -extern void _cpp_notify_macro_use (cpp_reader *pfile, cpp_hashnode *node); -inline void _cpp_maybe_notify_macro_use (cpp_reader *pfile, cpp_hashnode *node) +extern void _cpp_notify_macro_use (cpp_reader *pfile, cpp_hashnode *node, + location_t loc); +inline void _cpp_maybe_notify_macro_use (cpp_reader *pfile, cpp_hashnode *node, + location_t loc) { if (!(node->flags & NODE_USED)) - _cpp_notify_macro_use (pfile, node); + _cpp_notify_macro_use (pfile, node, loc); } extern cpp_macro *_cpp_new_macro (cpp_reader *, cpp_macro_kind, void *); extern void _cpp_free_definition (cpp_hashnode *); -- cgit v1.1