From 04acc378eb62c937576065668df01a23fa1b0680 Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Wed, 28 Mar 2018 05:04:59 +0000 Subject: [PATCH] [PR c++/84968] reject stmt-exprs in noexcept constexprs We reject extended statement-expressions in template parameters, so we might as well reject them in constant expressions used in noexcept specifications. for gcc/cp/ChangeLog PR c++/84968 * tree.c (strip_typedefs_expr): Reject STATEMENT_LISTs. for gcc/testsuite/ChangeLog PR c++/84968 * g++.dg/eh/pr84968.C: New. From-SVN: r258913 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/tree.c | 4 ++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/eh/pr84968.C | 15 +++++++++++++++ 4 files changed, 29 insertions(+) create mode 100644 gcc/testsuite/g++.dg/eh/pr84968.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4c029815b13..23f5d3a7e1b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-03-28 Alexandre Oliva + + PR c++/84968 + * tree.c (strip_typedefs_expr): Reject STATEMENT_LISTs. + 2018-03-27 Paolo Carlini PR c++/85067 diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 0355b9ed9c5..e75c88d6e8f 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1788,6 +1788,10 @@ strip_typedefs_expr (tree t, bool *remove_attributes) error ("lambda-expression in a constant expression"); return error_mark_node; + case STATEMENT_LIST: + error ("statement-expression in a constant expression"); + return error_mark_node; + default: break; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b195bd77bf5..929d4dd575a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-28 Alexandre Oliva + + PR c++/84968 + * g++.dg/eh/pr84968.C: New. + 2018-03-27 Michael Meissner PR target/84914 diff --git a/gcc/testsuite/g++.dg/eh/pr84968.C b/gcc/testsuite/g++.dg/eh/pr84968.C new file mode 100644 index 00000000000..23c49f477a8 --- /dev/null +++ b/gcc/testsuite/g++.dg/eh/pr84968.C @@ -0,0 +1,15 @@ +// { dg-do compile { target c++11 } } + +// { dg-options "" } + +union b; + +struct S { + template + void a() + try { + } catch (int () + noexcept (({ union b a; true; }))) // { dg-error "constant" } + { + } +}; -- 2.30.2