aboutsummaryrefslogtreecommitdiff
path: root/libcpp/include
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2025-12-10 23:11:26 +0800
committerJason Merrill <jason@redhat.com>2025-12-10 23:11:26 +0800
commit9783f6f2f67f9472fa428b984e4e045ee7b64f78 (patch)
treefdb1d37a23435694992b15208b07b93c7fb33992 /libcpp/include
parent23d71494fe0a6244b870db5a4f879b528903f52c (diff)
downloadgcc-9783f6f2f67f9472fa428b984e4e045ee7b64f78.zip
gcc-9783f6f2f67f9472fa428b984e4e045ee7b64f78.tar.gz
gcc-9783f6f2f67f9472fa428b984e4e045ee7b64f78.tar.bz2
c++/modules: #include <vector> -> import <bits/stdc++.h>
Since the standard library doesn't preclude an #include of a standard library header from bringing in declarations from other headers, we can translate an #include of any of the importable headers as an import of <bits/stdc++.h>. To reduce the amount of C++ standard knowledge encoded in libcpp, I extend the translate_include callback to allow it to suggest an alternate header to try translating. It's a bit awkward to bounce back and forth, but this seems like the right division of responsibilities. libcpp/ChangeLog: * include/cpplib.h (struct cpp_callbacks): Replace 'path' parameter with file, angle_brackets, and alternate name. (cpp_get_name): Declare. * files.cc (cpp_get_name): New. (_cpp_stack_include, _cpp_post_stack_file, _cpp_stack_file) (_cpp_stack_translated_file): Refactor, try alternate file. gcc/cp/ChangeLog: * module.cc (maybe_translate_include): Suggest <bits/stdc++.h> as an alternate for importable standard library headers. (importable_headers, is_importable_header): New. gcc/ChangeLog: * doc/invoke.texi (C++ Modules): Remove standard library header units from missing pieces, mention importable header redirection. gcc/testsuite/ChangeLog: * g++.dg/modules/compile-std1.C: Test <vector> translation.
Diffstat (limited to 'libcpp/include')
-rw-r--r--libcpp/include/cpplib.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index 16f030c..65e1bc6 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -860,7 +860,8 @@ struct cpp_callbacks
/* Maybe translate a #include into something else. Return a
cpp_buffer containing the translation if translating. */
char *(*translate_include) (cpp_reader *, line_maps *, location_t,
- const char *path);
+ _cpp_file *file, bool angle_brackets,
+ const char **alternate);
};
#ifdef VMS