[PATCH/middle-end/diagnostic] Do not warn about unused out of bounds array refs

Dirk Mueller dmueller@suse.de
Tue Mar 20 14:17:00 GMT 2007


Hi, 

Marcus Meissner showed me one case where tree-alias introduced an out of 
bounds array reference that wasn't used at all. Hence the patch below to 
suppress warnings about such artifically constructed cases. 

Bootstrapped, regtested on i686-suse-linux


Thanks,
Dirk


2007-03-20  Dirk Mueller <dmueller@suse.de>

        * tree-vrp.c (check_array_bounds): Do not warn about
        out of bounds array refs which are not immediately used.

--- tree-vrp.c
+++ tree-vrp.c
@@ -4112,6 +4112,10 @@ check_array_bounds (tree *tp, int *walk_
           or
 
           ssa_name = &array[-200]
+
+	  or 
+
+	  ssa_name = &array[-200]
           other_name = ssa_name + 300;
 
           which are sometimes
@@ -4123,9 +4127,10 @@ check_array_bounds (tree *tp, int *walk_
 
        if (TREE_CODE (stmt) == GIMPLE_MODIFY_STMT
            && TREE_CODE (GIMPLE_STMT_OPERAND (stmt, 0)) == SSA_NAME
-           && single_imm_use (GIMPLE_STMT_OPERAND (stmt, 0), &op, &use_stmt)
+	   && (has_zero_uses (GIMPLE_STMT_OPERAND (stmt, 0))
+	       || (single_imm_use (GIMPLE_STMT_OPERAND (stmt, 0), &op, &use_stmt)
            && TREE_CODE (use_stmt) == GIMPLE_MODIFY_STMT
-           && BINARY_CLASS_P (GIMPLE_STMT_OPERAND (use_stmt, 1)))
+		   && BINARY_CLASS_P (GIMPLE_STMT_OPERAND (use_stmt, 1)))))
          *walk_subtree = FALSE;
 
        while (*walk_subtree && handled_component_p (t))



More information about the Gcc-patches mailing list