From b0d11f1ed68727a85280e0ceb83bf77b5385902a Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Thu, 29 Aug 2019 14:06:32 +0000 Subject: [preprocessor] Include stacking https://gcc.gnu.org/ml/gcc-patches/2019-08/msg01971.html * internal.h (enum include_type): Add IT_MAIN, IT_DIRECTIVE_HWM, IT_HEADER_HWM. (_cpp_stack_file): Take include_type, not a bool. * files.c (_cpp_find_file): Refactor to not hide an if inside a for conditional. (should_stack_file): Break apart to ... (is_known_idempotent_file, has_unique_contents): ... these. (_cpp_stack_file): Replace IMPORT boolean with include_type enum. Refactor to use new predicates. Do linemap compensation here ... (_cpp_stack_include): ... not here. * init.c (cpp_read_main_file): Pass IT_MAIN to _cpp_stack_file. From-SVN: r275034 --- libcpp/internal.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libcpp/internal.h') diff --git a/libcpp/internal.h b/libcpp/internal.h index a86b587..d4768ae 100644 --- a/libcpp/internal.h +++ b/libcpp/internal.h @@ -123,6 +123,10 @@ enum include_type /* Non-directive including mechanisms. */ IT_CMDLINE, /* -include */ IT_DEFAULT, /* forced header */ + IT_MAIN, /* main */ + + IT_DIRECTIVE_HWM = IT_IMPORT + 1, /* Directives below this. */ + IT_HEADER_HWM = IT_DEFAULT + 1, /* Header files below this. */ }; union utoken @@ -671,8 +675,7 @@ extern _cpp_file *_cpp_find_file (cpp_reader *, const char *, cpp_dir *, extern bool _cpp_find_failed (_cpp_file *); extern void _cpp_mark_file_once_only (cpp_reader *, struct _cpp_file *); extern void _cpp_fake_include (cpp_reader *, const char *); -extern bool _cpp_stack_file (cpp_reader *, _cpp_file*, bool, - location_t); +extern bool _cpp_stack_file (cpp_reader *, _cpp_file*, include_type, location_t); extern bool _cpp_stack_include (cpp_reader *, const char *, int, enum include_type, location_t); extern int _cpp_compare_file_date (cpp_reader *, const char *, int); -- cgit v1.1