From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2122) id 97AC3386197D; Thu, 15 Apr 2021 19:03:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 97AC3386197D MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jason Merrill To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-8201] c++: noexcept error recursion [PR100101] X-Act-Checkin: gcc X-Git-Author: Jason Merrill X-Git-Refname: refs/heads/master X-Git-Oldrev: a25590f29d07a88f6bf1b2c1ab0e4e012725db98 X-Git-Newrev: 2efbbba16a0630fac8cadcd6d9e0ffaabfadb79f Message-Id: <20210415190335.97AC3386197D@sourceware.org> Date: Thu, 15 Apr 2021 19:03:35 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Apr 2021 19:03:35 -0000 https://gcc.gnu.org/g:2efbbba16a0630fac8cadcd6d9e0ffaabfadb79f commit r11-8201-g2efbbba16a0630fac8cadcd6d9e0ffaabfadb79f Author: Jason Merrill Date: Thu Apr 15 13:38:54 2021 -0400 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. Diff: --- gcc/cp/pt.c | 11 +++++++++++ gcc/cp/tree.c | 5 ----- gcc/testsuite/g++.dg/cpp0x/noexcept67.C | 26 ++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 0f119a55272..2190f83882a 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -3890,6 +3890,10 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data) (struct find_parameter_pack_data*)data; bool parameter_pack_p = false; +#define WALK_SUBTREE(NODE) \ + cp_walk_tree (&(NODE), &find_parameter_packs_r, \ + ppd, ppd->visited) \ + /* Don't look through typedefs; we are interested in whether a parameter pack is actually written in the expression/type we're looking at, not the target type. */ @@ -4070,10 +4074,17 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data) ppd, ppd->visited); return NULL_TREE; + case FUNCTION_TYPE: + case METHOD_TYPE: + WALK_SUBTREE (TYPE_RAISES_EXCEPTIONS (t)); + break; + default: return NULL_TREE; } +#undef WALK_SUBTREE + return NULL_TREE; } diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 13cc61c3123..dca947bf52a 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -5415,11 +5415,6 @@ cp_walk_subtrees (tree *tp, int *walk_subtrees_p, walk_tree_fn func, } break; - case FUNCTION_TYPE: - case METHOD_TYPE: - WALK_SUBTREE (TYPE_RAISES_EXCEPTIONS (*tp)); - break; - default: return NULL_TREE; } diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept67.C b/gcc/testsuite/g++.dg/cpp0x/noexcept67.C new file mode 100644 index 00000000000..7f061034323 --- /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(); +}