gcc/
        * gimple.h (gimple_cond_true_label): Require a const_gimple_cond
        rather than just a const_gimple.
        (gimple_cond_false_label): Likewise.

        * omp-low.c (diagnose_sb_2): Add checked cast to gimple_cond within
        case GIMPLE_COND.
        * tree-eh.c (maybe_record_in_goto_queue): Likewise.

        * tree-cfg.c (verify_gimple_stmt): Add a checked cast to gimple_cond
        within "case GIMPLE_COND", splitting it out into...
        (verify_gimple_label): New.
---
 gcc/gimple.h   |  7 +++----
 gcc/omp-low.c  |  5 +++--
 gcc/tree-cfg.c | 43 ++++++++++++++++++++++++++-----------------
 gcc/tree-eh.c  | 17 +++++++++++------
 4 files changed, 43 insertions(+), 29 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index bdb2162..9e60c4f 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3358,9 +3358,8 @@ gimple_cond_set_rhs (gimple gs, tree rhs)
    predicate evaluates to true.  */
 
 static inline tree
-gimple_cond_true_label (const_gimple gs)
+gimple_cond_true_label (const_gimple_cond gs)
 {
-  GIMPLE_CHECK (gs, GIMPLE_COND);
   return gimple_op (gs, 2);
 }
 
@@ -3389,9 +3388,9 @@ gimple_cond_set_false_label (gimple_cond gs, tree label)
    predicate evaluates to false.  */
 
 static inline tree
-gimple_cond_false_label (const_gimple gs)
+gimple_cond_false_label (const_gimple_cond gs)
 {
-  GIMPLE_CHECK (gs, GIMPLE_COND);
+
   return gimple_op (gs, 3);
 }
 
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index d5df743..b6d5674 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -10457,7 +10457,8 @@ diagnose_sb_2 (gimple_stmt_iterator *gsi_p, bool 
*handled_ops_p,
 
     case GIMPLE_COND:
        {
-         tree lab = gimple_cond_true_label (stmt);
+         gimple_cond cond_stmt = stmt->as_a_gimple_cond ();
+         tree lab = gimple_cond_true_label (cond_stmt);
          if (lab)
            {
              n = splay_tree_lookup (all_labels,
@@ -10465,7 +10466,7 @@ diagnose_sb_2 (gimple_stmt_iterator *gsi_p, bool 
*handled_ops_p,
              diagnose_sb_0 (gsi_p, context,
                             n ? (gimple) n->value : NULL);
            }
-         lab = gimple_cond_false_label (stmt);
+         lab = gimple_cond_false_label (cond_stmt);
          if (lab)
            {
              n = splay_tree_lookup (all_labels,
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 1000bbb..355c4ac 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -4406,6 +4406,31 @@ verify_gimple_label (gimple_label stmt)
   return err;
 }
 
+/* Verify a gimple cond statement STMT.
+   Returns true if anything is wrong.  */
+
+static bool
+verify_gimple_cond (gimple_cond stmt)
+{
+  if (TREE_CODE_CLASS (gimple_cond_code (stmt)) != tcc_comparison)
+    {
+      error ("invalid comparison code in gimple cond");
+      return true;
+    }
+  if (!(!gimple_cond_true_label (stmt)
+       || TREE_CODE (gimple_cond_true_label (stmt)) == LABEL_DECL)
+      || !(!gimple_cond_false_label (stmt)
+          || TREE_CODE (gimple_cond_false_label (stmt)) == LABEL_DECL))
+    {
+      error ("invalid labels in gimple cond");
+      return true;
+    }
+
+  return verify_gimple_comparison (boolean_type_node,
+                                  gimple_cond_lhs (stmt),
+                                  gimple_cond_rhs (stmt));
+}
+
 /* Verify the GIMPLE statement STMT.  Returns true if there is an
    error, otherwise false.  */
 
@@ -4424,23 +4449,7 @@ verify_gimple_stmt (gimple stmt)
       return verify_gimple_call (stmt->as_a_gimple_call ());
 
     case GIMPLE_COND:
-      if (TREE_CODE_CLASS (gimple_cond_code (stmt)) != tcc_comparison)
-       {
-         error ("invalid comparison code in gimple cond");
-         return true;
-       }
-      if (!(!gimple_cond_true_label (stmt)
-           || TREE_CODE (gimple_cond_true_label (stmt)) == LABEL_DECL)
-         || !(!gimple_cond_false_label (stmt)
-              || TREE_CODE (gimple_cond_false_label (stmt)) == LABEL_DECL))
-       {
-         error ("invalid labels in gimple cond");
-         return true;
-       }
-         
-      return verify_gimple_comparison (boolean_type_node,
-                                      gimple_cond_lhs (stmt),
-                                      gimple_cond_rhs (stmt));
+      return verify_gimple_cond (stmt->as_a_gimple_cond ());
 
     case GIMPLE_GOTO:
       return verify_gimple_goto (stmt->as_a_gimple_goto ());
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index aad6da3..46dcc20 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -695,12 +695,17 @@ maybe_record_in_goto_queue (struct leh_state *state, 
gimple stmt)
   switch (gimple_code (stmt))
     {
     case GIMPLE_COND:
-      new_stmt.tp = gimple_op_ptr (stmt, 2);
-      record_in_goto_queue_label (tf, new_stmt, gimple_cond_true_label (stmt),
-                                 EXPR_LOCATION (*new_stmt.tp));
-      new_stmt.tp = gimple_op_ptr (stmt, 3);
-      record_in_goto_queue_label (tf, new_stmt, gimple_cond_false_label (stmt),
-                                 EXPR_LOCATION (*new_stmt.tp));
+      {
+       gimple_cond cond_stmt = stmt->as_a_gimple_cond ();
+       new_stmt.tp = gimple_op_ptr (cond_stmt, 2);
+       record_in_goto_queue_label (tf, new_stmt,
+                                   gimple_cond_true_label (cond_stmt),
+                                   EXPR_LOCATION (*new_stmt.tp));
+       new_stmt.tp = gimple_op_ptr (cond_stmt, 3);
+       record_in_goto_queue_label (tf, new_stmt,
+                                   gimple_cond_false_label (cond_stmt),
+                                   EXPR_LOCATION (*new_stmt.tp));
+      }
       break;
     case GIMPLE_GOTO:
       new_stmt.g = stmt;
-- 
1.8.5.3

Reply via email to