diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/constraint.cc | 13 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp2a/concepts-friend9.C | 12 |
2 files changed, 16 insertions, 9 deletions
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index e14578b..c5a991b 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -1268,20 +1268,15 @@ remove_constraints (tree t) for declaration matching. */ tree -maybe_substitute_reqs_for (tree reqs, const_tree decl_) +maybe_substitute_reqs_for (tree reqs, const_tree decl) { if (reqs == NULL_TREE) return NULL_TREE; - tree decl = CONST_CAST_TREE (decl_); - tree result = STRIP_TEMPLATE (decl); - - if (DECL_UNIQUE_FRIEND_P (result)) + decl = STRIP_TEMPLATE (decl); + if (DECL_UNIQUE_FRIEND_P (decl) && DECL_TEMPLATE_INFO (decl)) { - tree tmpl = decl; - if (TREE_CODE (decl) != TEMPLATE_DECL) - tmpl = DECL_TI_TEMPLATE (result); - + tree tmpl = DECL_TI_TEMPLATE (decl); tree gargs = generic_targs_for (tmpl); processing_template_decl_sentinel s; if (uses_template_parms (gargs)) diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-friend9.C b/gcc/testsuite/g++.dg/cpp2a/concepts-friend9.C new file mode 100644 index 0000000..09054d23 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-friend9.C @@ -0,0 +1,12 @@ +// PR c++/105064 +// { dg-do compile { target c++20 } } + +struct A { + template<class T> + friend void f(T) requires true; +}; + +struct B { + template<class T> + friend void f(T) requires true; +}; |