]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++/modules: Fix ICE with multiple module declarations and -M [PR123738]
authorNathaniel Shead <nathanieloshead@gmail.com>
Sat, 31 Jan 2026 10:45:39 +0000 (21:45 +1100)
committerNathaniel Shead <nathanieloshead@gmail.com>
Sun, 8 Feb 2026 06:27:19 +0000 (17:27 +1100)
commitc6dd51c062667fdf2db3bed0ab50e034e048f3b5
tree44a72ce5307b253f4366dedbfc7f9b2b9f208ad5
parentca70335ceab761f3c3a365d0667ad824a7bf6822
c++/modules: Fix ICE with multiple module declarations and -M [PR123738]

When only doing preprocessing, we do not call declare_module, and so we
do not check that a module has been declared multiple times.  This means
we end up with multiple "primary modules" being passed to the dependency
producing logic, which asserts.  Fixed by checking if we've already seen
a module declaration and complaining.

PR c++/123738

gcc/cp/ChangeLog:

* module.cc (preprocess_module): Complain for any non-imported
module declaration in a module purview.

gcc/testsuite/ChangeLog:

* g++.dg/modules/dep-5.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/module.cc
gcc/testsuite/g++.dg/modules/dep-5.C [new file with mode: 0644]