tree-cfg.c (tree_verify_flow_info): Make sure that labels in SWITCH_LABELS are always...
authorSteven Bosscher <stevenb@suse.de>
Mon, 7 Jun 2004 06:11:59 +0000 (06:11 +0000)
committerSteven Bosscher <steven@gcc.gnu.org>
Mon, 7 Jun 2004 06:11:59 +0000 (06:11 +0000)
* tree-cfg.c (tree_verify_flow_info): Make sure that labels in
SWITCH_LABELS are always sorted.

From-SVN: r82683

gcc/ChangeLog
gcc/tree-cfg.c

index 7198e85..2a65c9f 100644 (file)
@@ -1,5 +1,10 @@
 2004-06-06  Steven Bosscher  <stevenb@suse.de>
 
+       * tree-cfg.c (tree_verify_flow_info): Make sure that labels in
+       SWITCH_LABELS are always sorted.
+
+2004-06-06  Steven Bosscher  <stevenb@suse.de>
+
        * hooks.c (hook_int_void_1): New generic hook.
        * hooks.h (hook_int_void_1): Add prototype.
        * config/c4x/c4x.c (TARGET_SCHED_USE_DFA_PIPELINE_INTERFACE):
index d6823cb..65e8e89 100644 (file)
@@ -3631,6 +3631,7 @@ tree_verify_flow_info (void)
 
        case SWITCH_EXPR:
          {
+           tree prev;
            edge e;
            size_t i, n;
            tree vec;
@@ -3649,6 +3650,34 @@ tree_verify_flow_info (void)
                label_bb->aux = (void *)1;
              }
 
+           /* Verify that the case labels are sorted.  */
+           prev = TREE_VEC_ELT (vec, 0);
+           for (i = 1; i < n - 1; ++i)
+             {
+               tree c = TREE_VEC_ELT (vec, i);
+               if (! CASE_LOW (c))
+                 {
+                   error ("Found default case not at end of case vector");
+                   err = 1;
+                   continue;
+                 }
+               if (! tree_int_cst_lt (CASE_LOW (prev), CASE_LOW (c)))
+                 {
+                   error ("Case labels not sorted:\n ");
+                   print_generic_expr (stderr, prev, 0);
+                   fprintf (stderr," is greater than ");
+                   print_generic_expr (stderr, c, 0);
+                   fprintf (stderr," but comes before it.\n");
+                   err = 1;
+                 }
+               prev = c;
+             }
+           if (CASE_LOW (TREE_VEC_ELT (vec, n - 1)))
+             {
+               error ("No default case found at end of case vector");
+               err = 1;
+             }
+
            for (e = bb->succ; e; e = e->succ_next)
              {
                if (!e->dest->aux)