diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index d9569013bd34806942dd10737ae660fc9a83f83c..49de3211d4c7e84b3ae48c9e15129eea5463e4c6 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -2134,7 +2134,8 @@ tsubst_compound_requirement (tree t, tree args, sat_info info) /* Check the noexcept condition. */ bool noexcept_p = COMPOUND_REQ_NOEXCEPT_P (t); - if (noexcept_p && !expr_noexcept_p (expr, quiet.complain)) + if (noexcept_p && !processing_template_decl + && !expr_noexcept_p (expr, quiet.complain)) { if (info.diagnose_unsatisfaction_p ()) inform (loc, "%qE is not %<noexcept%>", expr); @@ -2148,7 +2149,7 @@ tsubst_compound_requirement (tree t, tree args, sat_info info) return error_mark_node; /* Check expression against the result type. */ - if (type) + if (type && !processing_template_decl) { if (tree placeholder = type_uses_auto (type)) { diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-friend17.C b/gcc/testsuite/g++.dg/cpp2a/concepts-friend17.C new file mode 100644 index 0000000000000000000000000000000000000000..9b5091f14a811770fc2afb0ae080029d6dbc19a7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-friend17.C @@ -0,0 +1,15 @@ +// PR c++/113966 +// { dg-do compile { target c++20 } } + +template<class T> concept C = T::value; + +template<class T> +struct A { + template<class U> requires U::value || requires { { T() } -> C; } + friend void f(A, U) { } + + template<class U> requires requires { { g(U()) } noexcept; } + friend void f(A, U, U) { } +}; + +template struct A<int>;