From d4ddf7af75e164b67f16e47a64729b1262e824ea Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 16 Jun 2017 22:33:36 -0400 Subject: [PATCH] PR c++/80465 - ICE with generic lambda with noexcept-specifier. * lambda.c (maybe_add_lambda_conv_op): Keep processing_template_decl set longer for a generic lambda. From-SVN: r249328 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/lambda.c | 9 +++++---- gcc/testsuite/g++.dg/cpp1z/noexcept-type17.C | 7 +++++++ 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp1z/noexcept-type17.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f1d191faacb..664fa4f1224 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2017-06-16 Jason Merrill + PR c++/80465 - ICE with generic lambda with noexcept-specifier. + * lambda.c (maybe_add_lambda_conv_op): Keep processing_template_decl + set longer for a generic lambda. + PR c++/80614 - Wrong mangling for C++17 noexcept type * mangle.c (write_type): Put the eh spec back on the function type. diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index 46ab30f0a76..431823f7501 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -999,6 +999,8 @@ maybe_add_lambda_conv_op (tree type) null_pointer_node); if (generic_lambda_p) { + ++processing_template_decl; + /* Prepare the dependent member call for the static member function '_FUN' and, potentially, prepare another call to be used in a decltype return expression for a deduced return call op to allow for simple @@ -1048,9 +1050,7 @@ maybe_add_lambda_conv_op (tree type) if (generic_lambda_p) { - ++processing_template_decl; tree a = forward_parm (tgt); - --processing_template_decl; CALL_EXPR_ARG (call, ix) = a; if (decltype_call) @@ -1074,11 +1074,9 @@ maybe_add_lambda_conv_op (tree type) { if (decltype_call) { - ++processing_template_decl; fn_result = finish_decltype_type (decltype_call, /*id_expression_or_member_access_p=*/false, tf_warning_or_error); - --processing_template_decl; } } else @@ -1096,6 +1094,9 @@ maybe_add_lambda_conv_op (tree type) && TYPE_NOTHROW_P (TREE_TYPE (callop))) stattype = build_exception_variant (stattype, noexcept_true_spec); + if (generic_lambda_p) + --processing_template_decl; + /* First build up the conversion op. */ tree rettype = build_pointer_type (stattype); diff --git a/gcc/testsuite/g++.dg/cpp1z/noexcept-type17.C b/gcc/testsuite/g++.dg/cpp1z/noexcept-type17.C new file mode 100644 index 00000000000..46aefddedf8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/noexcept-type17.C @@ -0,0 +1,7 @@ +// PR c++/80465 +// { dg-options -std=c++1z } + +int foo(...); +int main() { + [](auto a) noexcept(noexcept(foo(a))){}(42); +}