mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
c++/modules: fix -MG for header units [PR123622]
With -MG we should allow a nonexistent header unit, as we do with a nonexistent #include. But still import it if available. PR c++/123622 gcc/cp/ChangeLog: * module.cc (preprocess_module): Check deps.missing_files. gcc/testsuite/ChangeLog: * g++.dg/modules/dep-6.C: New test. Co-authored-by: <mtxn@duck.com>
This commit is contained in:
@@ -23319,7 +23319,13 @@ preprocess_module (module_state *module, location_t from_loc,
|
||||
if (!(import->is_module ()
|
||||
&& (import->is_partition () || import->is_exported ()))
|
||||
&& import->loadedness == ML_NONE
|
||||
&& (import->is_header () || !flag_preprocess_only))
|
||||
&& (!flag_preprocess_only
|
||||
|| (import->is_header ()
|
||||
/* Allow a missing/unimportable GCM with -MG.
|
||||
FIXME We should also try falling back to #include
|
||||
before giving up entirely. */
|
||||
&& (!cpp_get_options (reader)->deps.missing_files
|
||||
|| import->check_importable (reader)))))
|
||||
{
|
||||
unsigned n = dump.push (import);
|
||||
import->do_import (reader, true);
|
||||
|
||||
6
gcc/testsuite/g++.dg/modules/dep-6.C
Normal file
6
gcc/testsuite/g++.dg/modules/dep-6.C
Normal file
@@ -0,0 +1,6 @@
|
||||
// PR c++/123622
|
||||
// { dg-additional-options "-fmodules -M -MG -MF dep-6.d" }
|
||||
|
||||
import "dep-6.h"; // Must not exist!
|
||||
|
||||
// { dg-final { scan-file dep-6.d {\nCXX_IMPORTS \+= \./dep-6\.h\.c\+\+-module} } }
|
||||
Reference in New Issue
Block a user