OSDN Git Service

2008-12-30 Andrew Pinski <pinskia@gmail.com>
authorpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 30 Dec 2008 16:27:29 +0000 (16:27 +0000)
committerpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 30 Dec 2008 16:27:29 +0000 (16:27 +0000)
        PR middle-end/38661
        * tree-switch-conversion.c (build_constructors): Test for wrapping of
        pos case.

2008-12-30  Andrew Pinski  <pinskia@gmail.com>

        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
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr38661-1.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/compile/pr38661.c [new file with mode: 0644]
gcc/tree-switch-conversion.c

index 87d22b4..89d19b0 100644 (file)
@@ -1,3 +1,9 @@
+2008-12-30  Andrew Pinski  <pinskia@gmail.com>
+
+       PR middle-end/38661
+       * tree-switch-conversion.c (build_constructors): Test for wrapping of
+       pos case.
+
 2008-12-30  Steven Bosscher  <steven@gcc.gnu.org>
 
        PR middle-end/38584
index 7c6dc8d..81e86b3 100644 (file)
@@ -1,3 +1,9 @@
+2008-12-30  Andrew Pinski  <pinskia@gmail.com>
+
+       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  <rguenther@suse.de>
 
        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 (file)
index 0000000..065f120
--- /dev/null
@@ -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 (file)
index 0000000..5d243c6
--- /dev/null
@@ -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 "";
+ }
+}
index 798cf16..dba0c6f 100644 (file)
@@ -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++;
        }
     }