c++/modules: Fix ICE in instantiating_tu_local_entity [PR122628]

I'd missed a STRIP_TEMPLATE when attempting to query whether DECL was
an imported entity.

	PR c++/122628

gcc/cp/ChangeLog:

	* module.cc (instantiating_tu_local_entity): Add missing
	STRIP_TEMPLATEs.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/internal-18.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
This commit is contained in:
Nathaniel Shead 2025-11-11 10:16:58 +11:00
parent 2fbb6b2618
commit 536ae8191f
2 changed files with 11 additions and 2 deletions

View File

@ -14231,8 +14231,8 @@ instantiating_tu_local_entity (tree decl)
return false;
tree origin = get_originating_module_decl (decl);
if (!DECL_LANG_SPECIFIC (origin)
|| !DECL_MODULE_IMPORT_P (origin))
if (!DECL_LANG_SPECIFIC (STRIP_TEMPLATE (origin))
|| !DECL_MODULE_IMPORT_P (STRIP_TEMPLATE (origin)))
return false;
/* Referencing TU-local entities from a header is generally OK.

View File

@ -0,0 +1,9 @@
// PR c++/122628
// { dg-additional-options "-fmodules" }
template <typename T> static void baz(T) {}
template <typename T> static void bar(T) { baz(0); }
void foo() {
bar(0);
}