diff options
author | Nathaniel Shead <nathanieloshead@gmail.com> | 2024-01-27 22:46:44 +1100 |
---|---|---|
committer | Nathaniel Shead <nathanieloshead@gmail.com> | 2024-01-30 14:48:53 +1100 |
commit | a88e08feb8367898e0562622517d33f95684a03d (patch) | |
tree | f8ba63308cdcf99bd73bf9dbbcf3a0b01a52770b | |
parent | 4822887b3c5df19b5a61a0db3248997a4d28161c (diff) | |
download | gcc-a88e08feb8367898e0562622517d33f95684a03d.zip gcc-a88e08feb8367898e0562622517d33f95684a03d.tar.gz gcc-a88e08feb8367898e0562622517d33f95684a03d.tar.bz2 |
c++: Handle error header names in modules [PR107594]
When there are no include paths while preprocessing a header-name token,
an empty STRING_CST is returned. This patch ensures this is handled when
attempting to create a module for this name.
PR c++/107594
gcc/cp/ChangeLog:
* module.cc (get_module): Bail on empty name.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
-rw-r--r-- | gcc/cp/module.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 840c7ef..3c2fef0e 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -14050,6 +14050,12 @@ get_primary (module_state *parent) module_state * get_module (tree name, module_state *parent, bool partition) { + /* We might be given an empty NAME if preprocessing fails to handle + a header-name token. */ + if (name && TREE_CODE (name) == STRING_CST + && TREE_STRING_LENGTH (name) == 0) + return nullptr; + if (partition) { if (!parent) |