diff options
-rw-r--r-- | gcc/cp/pt.cc | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/modules/tpl-friend-8_a.H | 9 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/modules/tpl-friend-8_b.C | 8 |
3 files changed, 25 insertions, 0 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 5b9fc58..b80e7ff 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -11448,6 +11448,14 @@ tsubst_friend_function (tree decl, tree args) by duplicate_decls. */ new_friend = old_decl; } + + /* We've just introduced a namespace-scope function in the purview + without necessarily having opened the enclosing namespace, so + make sure the namespace is in the purview now too. */ + if (modules_p () + && DECL_MODULE_PURVIEW_P (STRIP_TEMPLATE (new_friend)) + && TREE_CODE (DECL_CONTEXT (new_friend)) == NAMESPACE_DECL) + DECL_MODULE_PURVIEW_P (DECL_CONTEXT (new_friend)) = true; } else { diff --git a/gcc/testsuite/g++.dg/modules/tpl-friend-8_a.H b/gcc/testsuite/g++.dg/modules/tpl-friend-8_a.H new file mode 100644 index 0000000..bd22904 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/tpl-friend-8_a.H @@ -0,0 +1,9 @@ +// PR c++/100134 +// { dg-additional-options -fmodule-header } +// { dg-module-cmi {} } + +namespace std { + template<class T> struct A { + friend void f(A) { } + }; +} diff --git a/gcc/testsuite/g++.dg/modules/tpl-friend-8_b.C b/gcc/testsuite/g++.dg/modules/tpl-friend-8_b.C new file mode 100644 index 0000000..76d7447 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/tpl-friend-8_b.C @@ -0,0 +1,8 @@ +// PR c++/100134 +// { dg-additional-options -fmodules-ts } +// { dg-module-cmi pr100134 } +export module pr100134; + +import "tpl-friend-8_a.H"; + +export std::A<int> a; |