From 06dbc4ec2da3ed51918d2e510a88f5a58b006ef4 Mon Sep 17 00:00:00 2001 From: Volker Reichelt Date: Thu, 11 May 2006 15:16:49 +0000 Subject: [PATCH] re PR c++/27384 (ICE with invalid array size) PR middle-end/27384 * fold-const.c (size_binop): Move sanity check for arguments to the beginning of the function. * g++.dg/other/fold1.C: New test. From-SVN: r113703 --- gcc/ChangeLog | 6 ++++++ gcc/fold-const.c | 6 +++--- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/other/fold1.C | 8 ++++++++ 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/other/fold1.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index be18f843ad61..be9553d839b6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2006-05-11 Volker Reichelt + + PR middle-end/27384 + * fold-const.c (size_binop): Move sanity check for arguments to + the beginning of the function. + 2006-05-09 Richard Guenther PR tree-optimization/27136 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index d5575b48223a..3b4404e461ba 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -1633,6 +1633,9 @@ size_binop (enum tree_code code, tree arg0, tree arg1) { tree type = TREE_TYPE (arg0); + if (arg0 == error_mark_node || arg1 == error_mark_node) + return error_mark_node; + gcc_assert (TREE_CODE (type) == INTEGER_TYPE && TYPE_IS_SIZETYPE (type) && type == TREE_TYPE (arg1)); @@ -1652,9 +1655,6 @@ size_binop (enum tree_code code, tree arg0, tree arg1) return int_const_binop (code, arg0, arg1, 0); } - if (arg0 == error_mark_node || arg1 == error_mark_node) - return error_mark_node; - return fold (build2 (code, type, arg0, arg1)); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a15879b6a17d..26a789033666 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2006-05-11 Volker Reichelt + PR middle-end/27384 + * g++.dg/other/fold1.C: New test. + PR c++/27547 * g++.dg/other/operator1.C: New test. diff --git a/gcc/testsuite/g++.dg/other/fold1.C b/gcc/testsuite/g++.dg/other/fold1.C new file mode 100644 index 000000000000..f1f0dd9b99b5 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/fold1.C @@ -0,0 +1,8 @@ +// PR middle-end/27384 +// { dg-do compile } + +struct A +{ + static const int i = i; // { dg-error "not declared" } + int x[i]; // { dg-error "variable-size array" } +}; -- 2.47.2