From 7558c999cf1f05303e4d438b602cfd0d694f4838 Mon Sep 17 00:00:00 2001 From: pinskia Date: Tue, 30 Dec 2008 16:27:29 +0000 Subject: [PATCH] 2008-12-30 Andrew Pinski PR middle-end/38661 * tree-switch-conversion.c (build_constructors): Test for wrapping of pos case. 2008-12-30 Andrew Pinski PR middle-end/38661 * gcc.c-torture/compile/pr38661.c: New testcase. * gcc.c-torture/compile/pr38661-1.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@142964 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gcc.c-torture/compile/pr38661-1.c | 9 +++++++++ gcc/testsuite/gcc.c-torture/compile/pr38661.c | 9 +++++++++ gcc/tree-switch-conversion.c | 5 +++-- 5 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr38661-1.c create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr38661.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 87d22b4..89d19b0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-12-30 Andrew Pinski + + PR middle-end/38661 + * tree-switch-conversion.c (build_constructors): Test for wrapping of + pos case. + 2008-12-30 Steven Bosscher PR middle-end/38584 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7c6dc8d..81e86b3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-12-30 Andrew Pinski + + PR middle-end/38661 + * gcc.c-torture/compile/pr38661.c: New testcase. + * gcc.c-torture/compile/pr38661-1.c: New testcase. + 2008-12-30 Richard Guenther PR middle-end/38564 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr38661-1.c b/gcc/testsuite/gcc.c-torture/compile/pr38661-1.c new file mode 100644 index 0000000..065f120 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr38661-1.c @@ -0,0 +1,9 @@ +/* We used to ICE because we would wrap INT_MAX + into INT_MIN while doing the switch converison. */ + +const char *func(int val) { + switch (val) { + case - __INT_MAX__ -1 : return "foo"; + default: return ""; + } +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr38661.c b/gcc/testsuite/gcc.c-torture/compile/pr38661.c new file mode 100644 index 0000000..5d243c6 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr38661.c @@ -0,0 +1,9 @@ +/* We used to ICE because we would wrap INT_MAX + into INT_MIN while doing the switch converison. */ + +const char *func(int val) { + switch (val) { + case __INT_MAX__: return "foo"; + default: return ""; + } +} diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c index 798cf16..dba0c6f 100644 --- a/gcc/tree-switch-conversion.c +++ b/gcc/tree-switch-conversion.c @@ -440,9 +440,10 @@ build_constructors (gimple swtch) { gimple phi = gsi_stmt (gsi); tree val = PHI_ARG_DEF_FROM_EDGE (phi, e); + tree low = CASE_LOW (cs); pos = CASE_LOW (cs); - while (!tree_int_cst_lt (high, pos)) + do { constructor_elt *elt; @@ -452,7 +453,7 @@ build_constructors (gimple swtch) elt->value = val; pos = int_const_binop (PLUS_EXPR, pos, integer_one_node, 0); - } + } while (!tree_int_cst_lt (high, pos) && tree_int_cst_lt (low, pos)); j++; } } -- 2.7.4