------- Comment #17 from manu at gcc dot gnu dot org 2008-08-22 16:44 -------
The location passed to check_array_ref is correct but the new way to check if
we are in system headers does not work well with the %H hack. This will go away
soon hopefully when everything takes an explicit location. The fix is to use
warning_at. This kind of thing may happen in the middle-end and in the
front-end. This doesn't fix the bogus warning though, it just suppresses it
within system headers.
Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c (revision 139373)
+++ gcc/tree-vrp.c (working copy)
@@ -4811,11 +4811,11 @@ insert_range_assertions (void)
range. If the array subscript is a RANGE, warn if it is
non-overlapping with valid range.
IGNORE_OFF_BY_ONE is true if the ARRAY_REF is inside a ADDR_EXPR. */
static void
-check_array_ref (tree ref, const location_t *location, bool ignore_off_by_one)
+check_array_ref (tree ref, location_t location, bool ignore_off_by_one)
{
value_range_t* vr = NULL;
tree low_sub, up_sub;
tree low_bound, up_bound = array_ref_up_bound (ref);
@@ -4850,12 +4850,12 @@ check_array_ref (tree ref, const locatio
if (TREE_CODE (up_sub) == INTEGER_CST
&& tree_int_cst_lt (up_bound, up_sub)
&& TREE_CODE (low_sub) == INTEGER_CST
&& tree_int_cst_lt (low_sub, low_bound))
{
- warning (OPT_Warray_bounds,
- "%Harray subscript is outside array bounds", location);
+ warning_at (location, OPT_Warray_bounds,
+ "array subscript is outside array bounds");
TREE_NO_WARNING (ref) = 1;
}
}
else if (TREE_CODE (up_sub) == INTEGER_CST
&& tree_int_cst_lt (up_bound, up_sub)
@@ -4865,28 +4865,28 @@ check_array_ref (tree ref, const locatio
up_bound,
integer_one_node,
0),
up_sub)))
{
- warning (OPT_Warray_bounds, "%Harray subscript is above array bounds",
- location);
+ warning_at (location, OPT_Warray_bounds,
+ "array subscript is above array bounds");
TREE_NO_WARNING (ref) = 1;
}
else if (TREE_CODE (low_sub) == INTEGER_CST
&& tree_int_cst_lt (low_sub, low_bound))
{
- warning (OPT_Warray_bounds, "%Harray subscript is below array bounds",
- location);
+ warning_at (location, OPT_Warray_bounds,
+ "array subscript is below array bounds");
TREE_NO_WARNING (ref) = 1;
}
}
/* Searches if the expr T, located at LOCATION computes
address of an ARRAY_REF, and call check_array_ref on it. */
static void
-search_for_addr_array(tree t, const location_t *location)
+search_for_addr_array(tree t, location_t location)
{
while (TREE_CODE (t) == SSA_NAME)
{
gimple g = SSA_NAME_DEF_STMT (t);
@@ -4925,11 +4925,11 @@ search_for_addr_array(tree t, const loca
static tree
check_array_bounds (tree *tp, int *walk_subtree, void *data)
{
tree t = *tp;
struct walk_stmt_info *wi = (struct walk_stmt_info *) data;
- const location_t *location = (const location_t *) wi->info;
+ location_t location = *((location_t *) wi->info);
*walk_subtree = TRUE;
if (TREE_CODE (t) == ARRAY_REF)
check_array_ref (t, location, false /*ignore_off_by_one*/);
@@ -4972,11 +4972,11 @@ check_all_array_refs (void)
continue;
}
for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
{
gimple stmt = gsi_stmt (si);
- const location_t *location = gimple_location_ptr (stmt);
+ location_t location = gimple_location (stmt);
struct walk_stmt_info wi;
if (!gimple_has_location (stmt))
continue;
if (is_gimple_call (stmt))
@@ -4990,12 +4990,12 @@ check_all_array_refs (void)
}
}
else
{
memset (&wi, 0, sizeof (wi));
- wi.info = CONST_CAST (void *, (const void *) location);
-
+ /* wi.info = CONST_CAST (void *, (const void *)
&location);*/
+ wi.info = (void *) &location;
walk_gimple_op (gsi_stmt (si),
check_array_bounds,
&wi);
}
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36902