c++: header-unit build capability [PR 99023]
authorNathan Sidwell <nathan@acm.org>
Thu, 18 Feb 2021 20:46:25 +0000 (12:46 -0800)
committerNathan Sidwell <nathan@acm.org>
Thu, 18 Feb 2021 21:22:48 +0000 (13:22 -0800)
commit1f9db6929d926222aee0628b93f77cd20cf3adc4
treed00d2d912c714d8f13253ed49331aed0b66aed86
parentd82f829905cfe6cb47d073825f680900274ce764
c++: header-unit build capability [PR 99023]

This defect really required building header-units and include translation
of pieces of the standard library.  This adds smarts to the modules
test harness to do that -- accept .X files as the source file, but
provide '-x c++-system-header $HDR' in the options.  The .X file will
be considered by the driver to be a linker script and ignored (with a
warning).

Using this we can add 2 tests that end up building list_initializer
and iostream, along with a test that iostream's build
include-translates list_initializer's #include.  That discovered a set
of issues with the -flang-info-include-translate=HDR handling, also
fixed and documented here.

PR c++/99023
gcc/cp/
* module.cc (canonicalize_header_name): Use
cpp_probe_header_unit.
(maybe_translate_include): Fix note_includes comparison.
(init_modules): Fix note_includes string termination.
libcpp/
* include/cpplib.h (cpp_find_header_unit): Rename to ...
(cpp_probe_header_unit): ... this.
* internal.h (_cp_find_header_unit): Declare.
* files.c (cpp_find_header_unit): Break apart to ..
(test_header_unit): ... this, and ...
(_cpp_find_header_unit): ... and, or and ...
(cpp_probe_header_unit): ... this.
* macro.c (cpp_get_token_1): Call _cpp_find_header_unit.
gcc/
* doc/invoke.texi (flang-info-include-translate): Document header
lookup behaviour.
gcc/testsuite/
* g++.dg/modules/modules.exp: Bail on cross-testing.  Add support
for .X files.
* g++.dg/modules/pr99023_a.X: New.
* g++.dg/modules/pr99023_b.X: New.
gcc/cp/module.cc
gcc/doc/invoke.texi
gcc/testsuite/g++.dg/modules/modules.exp
gcc/testsuite/g++.dg/modules/pr99023_a.X [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/pr99023_b.X [new file with mode: 0644]
libcpp/files.c
libcpp/include/cpplib.h
libcpp/internal.h
libcpp/macro.c