From 4c60db9a7b033fc58a93fd93eb36a4f0bb311b63 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Fri, 21 Jun 2019 20:19:24 +0000 Subject: [PATCH] PR c++/90490 - fix decltype issues in noexcept-specifier. * except.c (build_noexcept_spec): Call instantiate_non_dependent_expr_sfinae before build_converted_constant_expr instead of calling instantiate_non_dependent_expr after it. Add processing_template_decl_sentinel. * g++.dg/cpp0x/noexcept43.C: New test. * g++.dg/cpp0x/noexcept44.C: New test. From-SVN: r272568 --- gcc/cp/ChangeLog | 9 +++++++++ gcc/cp/except.c | 4 +++- gcc/testsuite/ChangeLog | 8 +++++++- gcc/testsuite/g++.dg/cpp0x/noexcept43.C | 10 ++++++++++ gcc/testsuite/g++.dg/cpp0x/noexcept44.C | 8 ++++++++ 5 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/noexcept43.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/noexcept44.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c958318abe7..0afd0e6debf 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2019-06-21 Marek Polacek + + PR c++/90490 - fix decltype issues in noexcept-specifier. + * except.c (build_noexcept_spec): Call + instantiate_non_dependent_expr_sfinae before + build_converted_constant_expr instead of calling + instantiate_non_dependent_expr after it. Add + processing_template_decl_sentinel. + 2019-06-21 Jakub Jelinek PR c++/90950 diff --git a/gcc/cp/except.c b/gcc/cp/except.c index 892d5201da9..71f5d609f10 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -1285,8 +1285,10 @@ build_noexcept_spec (tree expr, tsubst_flags_t complain) if (TREE_CODE (expr) != DEFERRED_NOEXCEPT && !value_dependent_expression_p (expr)) { + expr = instantiate_non_dependent_expr_sfinae (expr, complain); + /* Don't let convert_like_real create more template codes. */ + processing_template_decl_sentinel s; expr = build_converted_constant_bool_expr (expr, complain); - expr = instantiate_non_dependent_expr (expr); expr = cxx_constant_value (expr); } if (TREE_CODE (expr) == INTEGER_CST) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2c80ac4bdd6..b56645fc0cf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-06-21 Marek Polacek + + PR c++/90490 - fix decltype issues in noexcept-specifier. + * g++.dg/cpp0x/noexcept43.C: New test. + * g++.dg/cpp0x/noexcept44.C: New test. + 2019-06-21 Matthew Beliveau PR c++/90875 - added -Wswitch-outside-range option @@ -13,7 +19,7 @@ 2019-06-21 Jeff Law - PR tree-optimization/90949 + PR tree-optimization/90949 * gcc.c-torture/execute/pr90949.c: New test. 2019-06-21 Marek Polacek diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept43.C b/gcc/testsuite/g++.dg/cpp0x/noexcept43.C new file mode 100644 index 00000000000..faa7d146029 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept43.C @@ -0,0 +1,10 @@ +// PR c++/90490 +// { dg-do compile { target c++11 } } + +struct R { constexpr operator bool() { return false;} }; + +template +struct S { + void g() noexcept(decltype(R{ }) { }) { + } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept44.C b/gcc/testsuite/g++.dg/cpp0x/noexcept44.C new file mode 100644 index 00000000000..78c9d12f2b7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept44.C @@ -0,0 +1,8 @@ +// PR c++/90490 +// { dg-do compile { target c++11 } } + +template +struct S { + void g() noexcept(decltype(int{ }) { }) { + } +}; -- 2.30.2