From 2efbbba16a0630fac8cadcd6d9e0ffaabfadb79f Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 15 Apr 2021 13:38:54 -0400 Subject: c++: noexcept error recursion [PR100101] Here instantiating the noexcept-specifier for bar() means instantiating A::value, which complains about the conversion from 0 to int* in the default argument of foo. Since my patch for PR99583, printing the error context involves looking at C::type, which again wants to instantiate A::value, which breaks. For now at least, let's break this recursion by avoiding looking into the noexcept-specifier in find_typenames, and limit that to just the uses_parameter_packs case that PR99583 cares about. gcc/cp/ChangeLog: PR c++/100101 PR c++/99583 * pt.c (find_parameter_packs_r) [FUNCTION_TYPE]: Walk into TYPE_RAISES_EXCEPTIONS here. * tree.c (cp_walk_subtrees): Not here. gcc/testsuite/ChangeLog: PR c++/100101 * g++.dg/cpp0x/noexcept67.C: New test. --- gcc/testsuite/g++.dg/cpp0x/noexcept67.C | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/noexcept67.C (limited to 'gcc/testsuite') diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept67.C b/gcc/testsuite/g++.dg/cpp0x/noexcept67.C new file mode 100644 index 0000000..7f06103 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept67.C @@ -0,0 +1,26 @@ +// PR c++/100101 +// { dg-do compile { target c++11 } } + +template struct A +{ + template static char foo(U*, int* = 0); + static const bool value = sizeof(foo(static_cast(nullptr))) > 0; +}; + +template struct B +{ + static const bool value = b; +}; + +template struct C +{ + typedef B::value> type; +}; + +template +void bar() noexcept(A::value && C::type::value) {} + +void baz() +{ + bar(); +} -- cgit v1.1