From: Jakub Jelinek Date: Thu, 21 Jul 2016 18:22:32 +0000 (+0200) Subject: re PR c++/71728 (ICE with goto in statement-expression inside a condition) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ab3af181e659954846e9d6678b04b2670f2da703;p=gcc.git re PR c++/71728 (ICE with goto in statement-expression inside a condition) PR c++/71728 * constexpr.c (potential_constant_expression_1) : Replace assert with test, return false if the goto isn't break or continue. Formatting fix. * g++.dg/other/pr71728.C: New test. From-SVN: r238601 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e7f5cb0dfbd..0ba456c76e5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2016-07-21 Jakub Jelinek + + PR c++/71728 + * constexpr.c (potential_constant_expression_1) : + Replace assert with test, return false if the goto isn't break + or continue. Formatting fix. + 2016-07-21 Richard Biener * vtable-class-hierarchy.c (vtv_generate_init_routine): Set diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 240c606f82c..f139260fb8b 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -5289,10 +5289,12 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, case GOTO_EXPR: { tree *target = &TREE_OPERAND (t, 0); - /* Gotos representing break and continue are OK; we should have - rejected other gotos in parsing. */ - gcc_assert (breaks (target) || continues (target)); - return true; + /* Gotos representing break and continue are OK. */ + if (breaks (target) || continues (target)) + return true; + if (flags & tf_error) + error ("% is not a constant-expression"); + return false; } default: @@ -5300,7 +5302,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, return false; sorry ("unexpected AST of kind %s", get_tree_code_name (TREE_CODE (t))); - gcc_unreachable(); + gcc_unreachable (); return false; } #undef RECUR diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d0b0c1d165d..0c03e52838d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-07-21 Jakub Jelinek + + PR c++/71728 + * g++.dg/other/pr71728.C: New test. + 2016-07-21 James Greenhalgh * gcc.dg/ifcvt-2.c: Use parameter to guide if-conversion heuristics. diff --git a/gcc/testsuite/g++.dg/other/pr71728.C b/gcc/testsuite/g++.dg/other/pr71728.C new file mode 100644 index 00000000000..b70e3c2f457 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr71728.C @@ -0,0 +1,11 @@ +// PR c++/71728 +// { dg-do compile } +// { dg-options "-std=gnu++14 -Wall" } + +int +foo () +{ + if (({ goto test; test: 1; }) != 1) + return 1; + return 2; +}