Bootstrapped and regtested on x86_64-pc-linux-gnu, and also ran dg.exp
with -fmodules enabled.  Pushing as obvious.

-- >8 --

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 <[email protected]>
---
 gcc/cp/module.cc                           | 4 ++--
 gcc/testsuite/g++.dg/modules/internal-18.C | 9 +++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/modules/internal-18.C

diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index a52dc0c7850..da9d29b4b01 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -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.
diff --git a/gcc/testsuite/g++.dg/modules/internal-18.C 
b/gcc/testsuite/g++.dg/modules/internal-18.C
new file mode 100644
index 00000000000..3f9102a1d47
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/internal-18.C
@@ -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);
+}
-- 
2.51.0

Reply via email to