On 1/10/26 6:30 AM, Patrick Palka wrote:
Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk?
OK.
-- >8 -- Since we now defer noexcept parsing for templated friends, some places need to be updated to cope with friend template specializations -- their TI_TEMPLATE is a TREE_LIST rather than a TEMPLATE_DECL, and they never introduce new template parameters. PR c++/123189 gcc/cp/ChangeLog: * name-lookup.cc (binding_to_template_parms_of_scope_p): Gracefully handle TEMPLATE_INFO whose TI_TEMPLATE is a TREE_LIST. * pt.cc (maybe_begin_member_template_processing): For a friend template specialization consider its class context instead. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/noexcept92.C: New test. --- gcc/cp/name-lookup.cc | 1 + gcc/cp/pt.cc | 4 ++-- gcc/testsuite/g++.dg/cpp0x/noexcept92.C | 11 +++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/noexcept92.C diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc index 8a7a81a9e324..f88510f65f1f 100644 --- a/gcc/cp/name-lookup.cc +++ b/gcc/cp/name-lookup.cc @@ -8004,6 +8004,7 @@ binding_to_template_parms_of_scope_p (cxx_binding *binding, /* The template of the current scope, iff said scope is a primary template. */ tmpl = (tinfo + && TREE_CODE (TI_TEMPLATE (tinfo)) == TEMPLATE_DECL && PRIMARY_TEMPLATE_P (TI_TEMPLATE (tinfo)) ? TI_TEMPLATE (tinfo) : NULL_TREE); diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index af2c7a767ab8..5a3b7549aa31 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -546,9 +546,9 @@ maybe_begin_member_template_processing (tree decl) int levels = 0; bool nsdmi = TREE_CODE (decl) == FIELD_DECL;- if (nsdmi)+ if (nsdmi || decl_specialization_friend_p (decl)) { - tree ctx = DECL_CONTEXT (decl); + tree ctx = nsdmi ? DECL_CONTEXT (decl) : DECL_CHAIN (decl); decl = (CLASSTYPE_TEMPLATE_INFO (ctx) /* Disregard full specializations (c++/60999). */ && uses_template_parms (ctx) diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept92.C b/gcc/testsuite/g++.dg/cpp0x/noexcept92.C new file mode 100644 index 000000000000..a3588582adae --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept92.C @@ -0,0 +1,11 @@ +// PR c++/123189 +// { dg-do compile { target c++11 } } + +template<class T> void f() noexcept(noexcept(T())); + +template<class T> +struct A { + friend void f<T>() noexcept(noexcept(T())); +}; + +template struct A<int>;
