diff options
author | Nathan Sidwell <nathan@acm.org> | 2020-11-02 08:29:58 -0800 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2020-11-02 08:56:38 -0800 |
commit | e9a2e208dd763bf71b0cc9db8526ef8f47ee289e (patch) | |
tree | 0d5f2dd77fcc92b927b3b4bbfb97f8cac4cb9a92 /libcpp/directives.c | |
parent | 1c689b827c6a0a5e164f22865696a94e6d7ec308 (diff) | |
download | gcc-e9a2e208dd763bf71b0cc9db8526ef8f47ee289e.zip gcc-e9a2e208dd763bf71b0cc9db8526ef8f47ee289e.tar.gz gcc-e9a2e208dd763bf71b0cc9db8526ef8f47ee289e.tar.bz2 |
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.
Diffstat (limited to 'libcpp/directives.c')
-rw-r--r-- | libcpp/directives.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/libcpp/directives.c b/libcpp/directives.c index f597187..d7b59aa 100644 --- a/libcpp/directives.c +++ b/libcpp/directives.c @@ -1134,6 +1134,7 @@ _cpp_do_file_change (cpp_reader *pfile, enum lc_reason reason, preprocessed source. */ line_map_ordinary *last = LINEMAPS_LAST_ORDINARY_MAP (pfile->line_table); if (!ORDINARY_MAP_STARTING_LINE_NUMBER (last) + && 0 == filename_cmp (to_file, ORDINARY_MAP_FILE_NAME (last)) && SOURCE_LINE (last, pfile->line_table->highest_line) == 2) { ord_map = last; @@ -1981,7 +1982,7 @@ do_ifdef (cpp_reader *pfile) { skip = !_cpp_defined_macro_p (node); _cpp_mark_macro_used (node); - _cpp_maybe_notify_macro_use (pfile, node); + _cpp_maybe_notify_macro_use (pfile, node, pfile->directive_line); if (pfile->cb.used) pfile->cb.used (pfile, pfile->directive_line, node); check_eol (pfile, false); @@ -2004,13 +2005,9 @@ do_ifndef (cpp_reader *pfile) if (node) { - /* Do not treat conditional macros as being defined. This is due to - the powerpc port using conditional macros for 'vector', 'bool', - and 'pixel' to act as conditional keywords. This messes up tests - like #ifndef bool. */ skip = _cpp_defined_macro_p (node); _cpp_mark_macro_used (node); - _cpp_maybe_notify_macro_use (pfile, node); + _cpp_maybe_notify_macro_use (pfile, node, pfile->directive_line); if (pfile->cb.used) pfile->cb.used (pfile, pfile->directive_line, node); check_eol (pfile, false); |