Fixing the error on checking for a non-existent header-unit, despite "-MG" being used. Resolving the bug 123622.
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 2d9b727d2b3..53e19644e22 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -23302,21 +23302,26 @@ preprocess_module (module_state *module, location_t from_loc,
timevar_start (TV_MODULE_IMPORT);
- /* Load the config of each pending import -- we must assign
- module numbers monotonically. */
- for (unsigned ix = 0; ix != pending_imports->length (); ix++)
+ if (!cpp_get_options (reader)->deps.missing_files ||
+ !flag_preprocess_only)
{
- auto *import = (*pending_imports)[ix];
- if (!(import->is_module ()
- && (import->is_partition () || import->is_exported ()))
- && import->loadedness == ML_NONE
- && (import->is_header () || !flag_preprocess_only))
+ /* Load the config of each pending import -- we must assign
+ module numbers monotonically. */
+ for (unsigned ix = 0; ix != pending_imports->length (); ix++)
{
- unsigned n = dump.push (import);
- import->do_import (reader, true);
- dump.pop (n);
+ auto *import = (*pending_imports)[ix];
+ if (!(import->is_module ()
+ && (import->is_partition () || import->is_exported ()))
+ && import->loadedness == ML_NONE
+ && import->is_header ())
+ {
+ unsigned n = dump.push (import);
+ import->do_import (reader, true);
+ dump.pop (n);
+ }
}
}
+
vec_free (pending_imports);
/* Restore the line-map state. */
diff --git a/gcc/testsuite/g++.dg/modules/123622.C b/gcc/testsuite/g++.dg/modules/123622.C
new file mode 100644
index 00000000000..401f29ee6c4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/123622.C
@@ -0,0 +1,5 @@
+// { dg-additional-options "-fmodules -M -MG -MF 123622.d" }
+
+import "123622.h"; // Must not exist!
+
+// { dg-final { scan-file 123622.d {\nCXX_IMPORTS \+= \./123622\.h\.c\+\+-module} } }
signature.asc
Description: OpenPGP digital signature
