preprocessor: main file searching

Nathan Sidwell nathan@acm.org
Thu Nov 19 15:04:59 GMT 2020


this patch is slightly modified from the original 07 patch, due to the 
cleanup I posted earlier today.

This adds the capability to locate the main file on the	user or	system
include paths.  That's extremely useful to users building header
units.  Searching has to be requiested (plain header-unit compilation
will not search).  Also, to make include_next work as expected when
building a header unit,	we add a mechanism to retrofit a non-searched
source file as one on the include path.

         libcpp/
         * include/cpplib.h (enum cpp_main_search): New.
         (struct cpp_options): Add main_search field.
         (cpp_main_loc): Declare.
         (cpp_retrofit_as_include): Declare.
         * internal.h (struct cpp_reader): Add main_loc field.
         (_cpp_in_main_source_file): Not main if main is a header.
         * init.c (cpp_read_main_file): Use main_search option to locate
         main file.  Set main_loc
         * files.c (cpp_retrofit_as_include): New.

pushing to trunk.

nathan
-- 
Nathan Sidwell
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 07.2-cpp-main.diff
Type: text/x-patch
Size: 5097 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20201119/fb391c21/attachment.bin>


More information about the Gcc-patches mailing list