From 65b309f7a50600adc8d0ae4dd8f62149875dc120 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 27 Feb 2019 10:02:23 +0000 Subject: [PATCH] re PR c++/89488 (ICE in merge_exception_specifiers, at cp/typeck2.c:2395) /cp 2019-02-27 Paolo Carlini PR c++/89488 * method.c (process_subob_fn): When maybe_instantiate_noexcept returns false don't call merge_exception_specifiers. /testsuite 2019-02-27 Paolo Carlini PR c++/89488 * g++.dg/cpp0x/nsdmi15.C: New. /cp 2019-02-27 Paolo Carlini PR c++/88987 * parser.c (cp_parser_noexcept_specification_opt): Return NULL_TREE for a non-constant parsed expression. /testsuite 2019-02-27 Paolo Carlini PR c++/88987 * g++.dg/cpp0x/pr88987.C: New. From-SVN: r269245 --- gcc/cp/ChangeLog | 12 ++++++++++++ gcc/cp/method.c | 10 +++++++--- gcc/cp/parser.c | 12 +++++++++++- gcc/testsuite/ChangeLog | 10 ++++++++++ gcc/testsuite/g++.dg/cpp0x/nsdmi15.C | 8 ++++++++ gcc/testsuite/g++.dg/cpp0x/pr88987.C | 9 +++++++++ 6 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/nsdmi15.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr88987.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6344e4e5feb..1ce758b15f6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,15 @@ +2019-02-27 Paolo Carlini + + PR c++/89488 + * method.c (process_subob_fn): When maybe_instantiate_noexcept + returns false don't call merge_exception_specifiers. + +2019-02-27 Paolo Carlini + + PR c++/88987 + * parser.c (cp_parser_noexcept_specification_opt): Return NULL_TREE + for a non-constant parsed expression. + 2019-02-26 Jakub Jelinek PR c++/89481 diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 6e0df68273e..477d3271f59 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -1256,9 +1256,13 @@ process_subob_fn (tree fn, tree *spec_p, bool *trivial_p, if (spec_p) { - maybe_instantiate_noexcept (fn); - tree raises = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn)); - *spec_p = merge_exception_specifiers (*spec_p, raises); + if (!maybe_instantiate_noexcept (fn)) + *spec_p = error_mark_node; + else + { + tree raises = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn)); + *spec_p = merge_exception_specifiers (*spec_p, raises); + } } if (!trivial_fn_p (fn) && !dtor_from_ctor) diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index e976008e94d..d9824e40803 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -25143,7 +25143,17 @@ cp_parser_noexcept_specification_opt (cp_parser* parser, parser->type_definition_forbidden_message = G_("types may not be defined in an exception-specification"); - expr = cp_parser_constant_expression (parser); + bool non_constant_p; + expr + = cp_parser_constant_expression (parser, + /*allow_non_constant=*/true, + &non_constant_p); + if (non_constant_p + && !require_potential_rvalue_constant_expression (expr)) + { + expr = NULL_TREE; + return_cond = true; + } /* Restore the saved message. */ parser->type_definition_forbidden_message = saved_message; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 71ff3fa9aa9..2365a4f8736 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2019-02-27 Paolo Carlini + + PR c++/89488 + * g++.dg/cpp0x/nsdmi15.C: New. + +2019-02-27 Paolo Carlini + + PR c++/88987 + * g++.dg/cpp0x/pr88987.C: New. + 2019-02-27 Jakub Jelinek PR tree-optimization/89280 diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi15.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi15.C new file mode 100644 index 00000000000..32bdad00962 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi15.C @@ -0,0 +1,8 @@ +// PR c++/89488 +// { dg-do compile { target c++11 } } + +struct zl { + struct { + int x2 = zl (); // { dg-error "default member" } + } fx; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr88987.C b/gcc/testsuite/g++.dg/cpp0x/pr88987.C new file mode 100644 index 00000000000..c26b571f559 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr88987.C @@ -0,0 +1,9 @@ +// { dg-do compile { target c++11 } } + +int sm; + +template T +pk () noexcept (sm) // { dg-error "constant expression" } +{ + return 0; +} -- 2.30.2