diff options
author | Nathan Sidwell <nathan@acm.org> | 2020-11-19 04:43:13 -0800 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2020-11-19 04:47:00 -0800 |
commit | bf425849f1dfa11f509e9ec251056d1e769b1ac2 (patch) | |
tree | d73bb29cb66ee8d64169758fd9f46c9abfe72b91 /libcpp/directives.c | |
parent | d84ba819fe2f8bf49eddb7a3f42299a49d0206ea (diff) | |
download | gcc-bf425849f1dfa11f509e9ec251056d1e769b1ac2.zip gcc-bf425849f1dfa11f509e9ec251056d1e769b1ac2.tar.gz gcc-bf425849f1dfa11f509e9ec251056d1e769b1ac2.tar.bz2 |
preprocessor: main-file cleanup
In preparing module patch 7 I realized there was a cleanup I could
make to simplify it. This is that cleanup. Also, when doing the
cleanup I noticed some macros had been turned into inline functions,
but not renamed to the preprocessors internal namespace
(_cpp_$INTERNAL rather than cpp_$USER). Thus, this renames those
functions, deletes an internal field of the file structure, and
determines whether we're in the main file by comparing to
pfile->main_file, the _cpp_file of the main file.
libcpp/
* internal.h (cpp_in_system_header): Rename to ...
(_cpp_in_system_header): ... here.
(cpp_in_primary_file): Rename to ...
(_cpp_in_main_source_file): ... here. Compare main_file equality
and check main_search value.
* lex.c (maybe_va_opt_error, _cpp_lex_direct): Adjust for rename.
* macro.c (_cpp_builtin_macro_text): Likewise.
(replace_args): Likewise.
* directives.c (do_include_next): Likewise.
(do_pragma_once, do_pragma_system_header): Likewise.
* files.c (struct _cpp_file): Delete main_file field.
(pch_open): Check pfile->main_file equality.
(make_cpp_file): Drop cpp_reader parm, don't set main_file.
(_cpp_find_file): Adjust.
(_cpp_stack_file): Check pfile->main_file equality.
(struct report_missing_guard_data): Add cpp_reader field.
(report_missing_guard): Check pfile->main_file equality.
(_cpp_report_missing_guards): Adjust.
Diffstat (limited to 'libcpp/directives.c')
-rw-r--r-- | libcpp/directives.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libcpp/directives.c b/libcpp/directives.c index c4ecb96..bffdc91 100644 --- a/libcpp/directives.c +++ b/libcpp/directives.c @@ -877,7 +877,7 @@ do_include_next (cpp_reader *pfile) /* If this is the primary source file, warn and use the normal search logic. */ - if (cpp_in_primary_file (pfile)) + if (_cpp_in_main_source_file (pfile)) { cpp_error (pfile, CPP_DL_WARNING, "#include_next in primary source file"); @@ -1546,7 +1546,7 @@ do_pragma (cpp_reader *pfile) static void do_pragma_once (cpp_reader *pfile) { - if (cpp_in_primary_file (pfile)) + if (_cpp_in_main_source_file (pfile)) cpp_error (pfile, CPP_DL_WARNING, "#pragma once in main file"); check_eol (pfile, false); @@ -1708,7 +1708,7 @@ do_pragma_poison (cpp_reader *pfile) static void do_pragma_system_header (cpp_reader *pfile) { - if (cpp_in_primary_file (pfile)) + if (_cpp_in_main_source_file (pfile)) cpp_error (pfile, CPP_DL_WARNING, "#pragma system_header ignored outside include file"); else |