diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-07-21 20:22:32 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-07-21 20:22:32 +0200 |
commit | ab3af181e659954846e9d6678b04b2670f2da703 (patch) | |
tree | d000ebcc5df973311f7d43bf526147286ac81f1b | |
parent | 1c4b8a04494fbd90ac41fd07158ab88410865b88 (diff) | |
download | gcc-ab3af181e659954846e9d6678b04b2670f2da703.zip gcc-ab3af181e659954846e9d6678b04b2670f2da703.tar.gz gcc-ab3af181e659954846e9d6678b04b2670f2da703.tar.bz2 |
re PR c++/71728 (ICE with goto in statement-expression inside a condition)
PR c++/71728
* constexpr.c (potential_constant_expression_1) <case GOTO_EXPR>:
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
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/constexpr.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/other/pr71728.C | 11 |
4 files changed, 30 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e7f5cb0..0ba456c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2016-07-21 Jakub Jelinek <jakub@redhat.com> + + PR c++/71728 + * constexpr.c (potential_constant_expression_1) <case GOTO_EXPR>: + Replace assert with test, return false if the goto isn't break + or continue. Formatting fix. + 2016-07-21 Richard Biener <rguenther@suse.de> * vtable-class-hierarchy.c (vtv_generate_init_routine): Set diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 240c606..f139260 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 ("%<goto%> 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 d0b0c1d..0c03e52 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-07-21 Jakub Jelinek <jakub@redhat.com> + + PR c++/71728 + * g++.dg/other/pr71728.C: New test. + 2016-07-21 James Greenhalgh <james.greenhalgh@arm.com> * 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 0000000..b70e3c2 --- /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; +} |