This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] tree-cfg.c: Make find_taken_edge safer.
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 02 Nov 2004 18:03:55 -0500 (EST)
- Subject: [patch] tree-cfg.c: Make find_taken_edge safer.
Hi,
Attached is a patch to make find_taken_edge safer.
All callers of find_taken_edge call it with a basic block ending with
COND_EXPR or SWITCH_EXPR.
The patch teaches find_taken_edge to abort if it is given something
else. There is no point asking find_taken_edge to handle something it
cannot handle.
Tested on i686-pc-linux-gnu. OK to apply?
Kazu Hirata
2004-11-02 Kazu Hirata <kazu@cs.umass.edu>
* tree-cfg.c (find_taken_edge): Abort if we are given a
statement that is neither COND_EXPR nor SWITCH_EXPR.
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.94
diff -u -d -p -r2.94 tree-cfg.c
--- tree-cfg.c 28 Oct 2004 13:31:40 -0000 2.94
+++ tree-cfg.c 31 Oct 2004 18:30:19 -0000
@@ -1942,9 +1942,9 @@ cleanup_control_expr_graph (basic_block
}
-/* Given a control block BB and a predicate VAL, return the edge that
- will be taken out of the block. If VAL does not match a unique
- edge, NULL is returned. */
+/* Given a basic block BB ending with COND_EXPR or SWITCH_EXPR, and a
+ predicate VAL, return the edge that will be taken out of the block.
+ If VAL does not match a unique edge, NULL is returned. */
edge
find_taken_edge (basic_block bb, tree val)
@@ -1972,7 +1972,7 @@ find_taken_edge (basic_block bb, tree va
if (TREE_CODE (stmt) == SWITCH_EXPR)
return find_taken_edge_switch_expr (bb, val);
- return EDGE_SUCC (bb, 0);
+ gcc_unreachable ();
}