From 3fd156b1bb5bb993e1b614008ac1a0eff58a6953 Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Fri, 14 Dec 2018 21:57:07 +0000 Subject: [PATCH] [PR c++/87814] undefer deferred noexcept on tsubst if request tsubst_expr and tsubst_copy_and_build are not expected to handle DEFERRED_NOEXCEPT exprs, but if tsubst_exception_specification takes a DEFERRED_NOEXCEPT expr with !defer_ok, it just passes the expr on for tsubst_copy_and_build to barf. This patch arranges for tsubst_exception_specification to combine the incoming args with those already stored in a DEFERRED_NOEXCEPT, and then substitute them into the pattern, when retaining a deferred noexcept is unacceptable. for gcc/cp/ChangeLog PR c++/87814 * pt.c (tsubst_exception_specification): Handle DEFERRED_NOEXCEPT with !defer_ok. for gcc/testsuite/ChangeLog PR c++/87814 * g++.dg/cpp1z/pr87814.C: New. From-SVN: r267155 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 14 +++++++++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp1z/pr87814.C | 26 ++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp1z/pr87814.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0467ca27761..2dfb1fed613 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-12-14 Alexandre Oliva + + PR c++/87814 + * pt.c (tsubst_exception_specification): Handle + DEFERRED_NOEXCEPT with !defer_ok. + 2018-12-14 Jason Merrill PR c++/86823 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 3b378ee9ff4..20f0d16efe1 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -14151,9 +14151,17 @@ tsubst_exception_specification (tree fntype, } } else - new_specs = tsubst_copy_and_build - (expr, args, complain, in_decl, /*function_p=*/false, - /*integral_constant_expression_p=*/true); + { + if (DEFERRED_NOEXCEPT_SPEC_P (specs)) + { + args = add_to_template_args (DEFERRED_NOEXCEPT_ARGS (expr), + args); + expr = DEFERRED_NOEXCEPT_PATTERN (expr); + } + new_specs = tsubst_copy_and_build + (expr, args, complain, in_decl, /*function_p=*/false, + /*integral_constant_expression_p=*/true); + } new_specs = build_noexcept_spec (new_specs, complain); } else if (specs) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a0879161104..9c24e473e5f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-12-14 Alexandre Oliva + + PR c++/87814 + * g++.dg/cpp1z/pr87814.C: New. + 2018-12-14 H.J. Lu * gcc.target/i386/cf_check-1.c: New test. diff --git a/gcc/testsuite/g++.dg/cpp1z/pr87814.C b/gcc/testsuite/g++.dg/cpp1z/pr87814.C new file mode 100644 index 00000000000..37034bb58cd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/pr87814.C @@ -0,0 +1,26 @@ +// { dg-do compile { target c++17 } } + +template +struct box { + template + constexpr box(E && e) + noexcept(noexcept(Element(e))) + {} +}; + +template +struct compressed_tuple_ : box ... { + template + constexpr compressed_tuple_(Args &&... args) + noexcept((noexcept(box(args)) && ...)) + : box(args)... + {} +}; + +struct adaptor_cursor : compressed_tuple_ { + using compressed_tuple_::compressed_tuple_; +}; + +int main() { + (void)noexcept(adaptor_cursor{(int*)0}); +} -- 2.30.2