From 7853504d63ff5c13c0f64e09d4515ea0ce67ffb8 Mon Sep 17 00:00:00 2001 From: Steven Bosscher Date: Mon, 7 Jun 2004 06:11:59 +0000 Subject: [PATCH] tree-cfg.c (tree_verify_flow_info): Make sure that labels in SWITCH_LABELS are always sorted. * tree-cfg.c (tree_verify_flow_info): Make sure that labels in SWITCH_LABELS are always sorted. From-SVN: r82683 --- gcc/ChangeLog | 5 +++++ gcc/tree-cfg.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7198e8568f0..2a65c9f19bd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2004-06-06 Steven Bosscher + + * tree-cfg.c (tree_verify_flow_info): Make sure that labels in + SWITCH_LABELS are always sorted. + 2004-06-06 Steven Bosscher * hooks.c (hook_int_void_1): New generic hook. diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index d6823cb5216..65e8e89ab78 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -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) -- 2.30.2