From: Jason Merrill Date: Mon, 12 Aug 2019 17:46:32 +0000 (-0400) Subject: PR c++/91378 - ICE with noexcept and auto return type. X-Git-Tag: releases/gcc-9.3.0~744 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b8c26032610d97d92a4d14a9ebb693fec0f75b8;p=thirdparty%2Fgcc.git PR c++/91378 - ICE with noexcept and auto return type. Here, since the call to g is not type-dependent, we call mark_used on it to determine its return type. This also wants to instantiate the noexcept-expression. But since nothing in maybe_instantiate_noexcept was calling push_to_top_level, we substituted b.i with processing_template_decl set, so we left it unresolved for later access checking. As a result, the type of C::g remained instantiation-dependent, leading to an ICE in type_dependent_expression_p on the assert that the type of a function template with no dependent template arguments must be non-dependent. * pt.c (maybe_instantiate_noexcept): push_to_top_level. From-SVN: r274316 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9a34a4f128e2..67ce26866bb9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2019-08-12 Jason Merrill + PR c++/91378 - ICE with noexcept and auto return type. + * pt.c (maybe_instantiate_noexcept): push_to_top_level. + PR c++/90538 - multiple expansions of capture packs * cp-tree.h (DECLTYPE_FOR_INIT_CAPTURE): Remove. * lambda.c (add_capture): Copy parameter packs from init. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index dd2dd2940bfe..b3fe901097c8 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -24323,12 +24323,11 @@ maybe_instantiate_noexcept (tree fn, tsubst_flags_t complain) } else if (push_tinst_level (fn)) { + push_to_top_level (); push_access_scope (fn); push_deferring_access_checks (dk_no_deferred); input_location = DECL_SOURCE_LOCATION (fn); - tree save_ccp = current_class_ptr; - tree save_ccr = current_class_ref; /* If needed, set current_class_ptr for the benefit of tsubst_copy/PARM_DECL. */ tree tdecl = DECL_TEMPLATE_RESULT (DECL_TI_TEMPLATE (fn)); @@ -24354,9 +24353,6 @@ maybe_instantiate_noexcept (tree fn, tsubst_flags_t complain) /*function_p=*/false, /*i_c_e_p=*/true); - current_class_ptr = save_ccp; - current_class_ref = save_ccr; - /* Build up the noexcept-specification. */ spec = build_noexcept_spec (noex, tf_warning_or_error); @@ -24366,6 +24362,7 @@ maybe_instantiate_noexcept (tree fn, tsubst_flags_t complain) pop_deferring_access_checks (); pop_access_scope (fn); pop_tinst_level (); + pop_from_top_level (); } else spec = noexcept_false_spec; diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn56.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn56.C new file mode 100644 index 000000000000..69bdd9586eb9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn56.C @@ -0,0 +1,19 @@ +// PR c++/91378 +// { dg-do compile { target c++14 } } + +struct B +{ + int i; +}; + +struct C +{ + template static auto + g(B b) noexcept(noexcept(b.i)) { } +}; + +template +void h(T t) +{ + C::g({}); +}