Hi,
as discussed with Martin, this patch consolidates -Warray-bounds into an
alias of -Warray-bounds=1.
Bootstrapped on x86_64-linux, no regressions.
Please apply if it's OK.
Franz.
gcc/ChangeLog:
2018-07-25 Franz Sirl <franz.sirl-ker...@lauterbach.com>
* common.opt: Alias -Warray-bounds to -Warray-bounds=1.
* builtins.c (c_strlen): Use OPT_Warray_bounds_.
* gimple-ssa-warn-restrict.c (maybe_diag_offset_bounds): Likewise.
* tree-vrp.c (vrp_prop::check_array_ref, vrp_prop::check_mem_ref,
vrp_prop::search_for_addr_array): Likewise.
gcc/c-family/ChangeLog:
2018-07-25 Franz Sirl <franz.sirl-ker...@lauterbach.com>
* c.opt: Remove -Warray-bounds.
* c-common.c (fold_offsetof, convert_vector_to_array_for_subscript):
Use OPT_Warray_bounds_.
Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c (revision 262966)
+++ gcc/builtins.c (working copy)
@@ -675,7 +675,7 @@ c_strlen (tree src, int only_value)
if (only_value != 2
&& !TREE_NO_WARNING (src))
{
- warning_at (loc, OPT_Warray_bounds,
+ warning_at (loc, OPT_Warray_bounds_,
"offset %qwi outside bounds of constant string",
eltoff);
TREE_NO_WARNING (src) = 1;
Index: gcc/c-family/c-common.c
===================================================================
--- gcc/c-family/c-common.c (revision 262966)
+++ gcc/c-family/c-common.c (working copy)
@@ -6257,7 +6257,7 @@ fold_offsetof (tree expr, tree type, enum tree_cod
definition thereof. */
if (TREE_CODE (v) == ARRAY_REF
|| TREE_CODE (v) == COMPONENT_REF)
- warning (OPT_Warray_bounds,
+ warning (OPT_Warray_bounds_,
"index %E denotes an offset "
"greater than size of %qT",
t, TREE_TYPE (TREE_OPERAND (expr, 0)));
@@ -7662,7 +7662,7 @@ convert_vector_to_array_for_subscript (location_t
if (TREE_CODE (index) == INTEGER_CST)
if (!tree_fits_uhwi_p (index)
|| maybe_ge (tree_to_uhwi (index), TYPE_VECTOR_SUBPARTS (type)))
- warning_at (loc, OPT_Warray_bounds, "index value is out of bound");
+ warning_at (loc, OPT_Warray_bounds_, "index value is out of bound");
/* We are building an ARRAY_REF so mark the vector as addressable
to not run into the gimplifiers premature setting of DECL_GIMPLE_REG_P
Index: gcc/c-family/c.opt
===================================================================
--- gcc/c-family/c.opt (revision 262966)
+++ gcc/c-family/c.opt (working copy)
@@ -326,10 +326,6 @@ Wno-alloca-larger-than
C ObjC C++ LTO ObjC++ Alias(Walloca-larger-than=,18446744073709551615EiB,none)
Warning
-Wno-alloca-larger-than Disable Walloca-larger-than= warning. Equivalent to
Walloca-larger-than=<SIZE_MAX> or larger.
-Warray-bounds
-LangEnabledBy(C ObjC C++ LTO ObjC++)
-; in common.opt
-
Warray-bounds=
LangEnabledBy(C ObjC C++ LTO ObjC++,Wall,1,0)
; in common.opt
Index: gcc/common.opt
===================================================================
--- gcc/common.opt (revision 262966)
+++ gcc/common.opt (working copy)
@@ -539,8 +539,7 @@ Common Var(warn_aggressive_loop_optimizations) Ini
Warn if a loop with constant number of iterations triggers undefined behavior.
Warray-bounds
-Common Var(warn_array_bounds) Warning
-Warn if an array is accessed out of bounds.
+Common Warning Alias(Warray-bounds=,1,0)
Warray-bounds=
Common Joined RejectNegative UInteger Var(warn_array_bounds) Warning
IntegerRange(0, 2)
Index: gcc/gimple-ssa-warn-restrict.c
===================================================================
--- gcc/gimple-ssa-warn-restrict.c (revision 262966)
+++ gcc/gimple-ssa-warn-restrict.c (working copy)
@@ -1619,7 +1619,7 @@ maybe_diag_offset_bounds (location_t loc, gcall *c
if (DECL_P (ref.base)
&& TREE_CODE (type = TREE_TYPE (ref.base)) == ARRAY_TYPE)
{
- if (warning_at (loc, OPT_Warray_bounds,
+ if (warning_at (loc, OPT_Warray_bounds_,
"%G%qD pointer overflow between offset %s "
"and size %s accessing array %qD with type %qT",
call, func, rangestr[0], rangestr[1], ref.base, type))
@@ -1629,13 +1629,13 @@ maybe_diag_offset_bounds (location_t loc, gcall *c
warned = true;
}
else
- warned = warning_at (loc, OPT_Warray_bounds,
+ warned = warning_at (loc, OPT_Warray_bounds_,
"%G%qD pointer overflow between offset %s "
"and size %s",
call, func, rangestr[0], rangestr[1]);
}
else
- warned = warning_at (loc, OPT_Warray_bounds,
+ warned = warning_at (loc, OPT_Warray_bounds_,
"%G%qD pointer overflow between offset %s "
"and size %s",
call, func, rangestr[0], rangestr[1]);
@@ -1652,7 +1652,7 @@ maybe_diag_offset_bounds (location_t loc, gcall *c
if (DECL_P (ref.base))
{
if ((ref.basesize < maxobjsize
- && warning_at (loc, OPT_Warray_bounds,
+ && warning_at (loc, OPT_Warray_bounds_,
form
? G_("%G%qD forming offset %s is out of "
"the bounds [0, %wu] of object %qD with "
@@ -1661,7 +1661,7 @@ maybe_diag_offset_bounds (location_t loc, gcall *c
"[0, %wu] of object %qD with type %qT"),
call, func, rangestr[0], ref.basesize.to_uhwi (),
ref.base, TREE_TYPE (ref.base)))
- || warning_at (loc, OPT_Warray_bounds,
+ || warning_at (loc, OPT_Warray_bounds_,
form
? G_("%G%qD forming offset %s is out of "
"the bounds of object %qD with type %qT")
@@ -1676,7 +1676,7 @@ maybe_diag_offset_bounds (location_t loc, gcall *c
}
}
else if (ref.basesize < maxobjsize)
- warned = warning_at (loc, OPT_Warray_bounds,
+ warned = warning_at (loc, OPT_Warray_bounds_,
form
? G_("%G%qD forming offset %s is out "
"of the bounds [0, %wu]")
@@ -1684,7 +1684,7 @@ maybe_diag_offset_bounds (location_t loc, gcall *c
"of the bounds [0, %wu]"),
call, func, rangestr[0], ref.basesize.to_uhwi ());
else
- warned = warning_at (loc, OPT_Warray_bounds,
+ warned = warning_at (loc, OPT_Warray_bounds_,
form
? G_("%G%qD forming offset %s is out of bounds")
: G_("%G%qD offset %s is out of bounds"),
@@ -1697,7 +1697,7 @@ maybe_diag_offset_bounds (location_t loc, gcall *c
type = TREE_TYPE (type);
type = TYPE_MAIN_VARIANT (type);
- warned = warning_at (loc, OPT_Warray_bounds,
+ warned = warning_at (loc, OPT_Warray_bounds_,
"%G%qD offset %s from the object at %qE is out "
"of the bounds of %qT",
call, func, rangestr[0], ref.base, type);
@@ -1706,7 +1706,7 @@ maybe_diag_offset_bounds (location_t loc, gcall *c
{
tree type = TYPE_MAIN_VARIANT (TREE_TYPE (ref.ref));
- warned = warning_at (loc, OPT_Warray_bounds,
+ warned = warning_at (loc, OPT_Warray_bounds_,
"%G%qD offset %s from the object at %qE is out "
"of the bounds of referenced subobject %qD with "
"type %qT at offset %wu",
Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c (revision 262966)
+++ gcc/tree-vrp.c (working copy)
@@ -4841,7 +4841,7 @@ vrp_prop::check_array_ref (location_t location, tr
/* Empty array. */
if (up_bound && tree_int_cst_equal (low_bound, up_bound_p1))
{
- warning_at (location, OPT_Warray_bounds,
+ warning_at (location, OPT_Warray_bounds_,
"array subscript %E is above array bounds of %qT",
low_bound, artype);
TREE_NO_WARNING (ref) = 1;
@@ -4867,7 +4867,7 @@ vrp_prop::check_array_ref (location_t location, tr
&& TREE_CODE (low_sub) == INTEGER_CST
&& tree_int_cst_le (low_sub, low_bound))
{
- warning_at (location, OPT_Warray_bounds,
+ warning_at (location, OPT_Warray_bounds_,
"array subscript [%E, %E] is outside array bounds of %qT",
low_sub, up_sub, artype);
TREE_NO_WARNING (ref) = 1;
@@ -4885,7 +4885,7 @@ vrp_prop::check_array_ref (location_t location, tr
dump_generic_expr (MSG_NOTE, TDF_SLIM, ref);
fprintf (dump_file, "\n");
}
- warning_at (location, OPT_Warray_bounds,
+ warning_at (location, OPT_Warray_bounds_,
"array subscript %E is above array bounds of %qT",
up_sub, artype);
TREE_NO_WARNING (ref) = 1;
@@ -4899,7 +4899,7 @@ vrp_prop::check_array_ref (location_t location, tr
dump_generic_expr (MSG_NOTE, TDF_SLIM, ref);
fprintf (dump_file, "\n");
}
- warning_at (location, OPT_Warray_bounds,
+ warning_at (location, OPT_Warray_bounds_,
"array subscript %E is below array bounds of %qT",
low_sub, artype);
TREE_NO_WARNING (ref) = 1;
@@ -5135,12 +5135,12 @@ vrp_prop::check_mem_ref (location_t location, tree
}
if (offrange[0] == offrange[1])
- warning_at (location, OPT_Warray_bounds,
+ warning_at (location, OPT_Warray_bounds_,
"array subscript %wi is outside array bounds "
"of %qT",
offrange[0].to_shwi (), reftype);
else
- warning_at (location, OPT_Warray_bounds,
+ warning_at (location, OPT_Warray_bounds_,
"array subscript [%wi, %wi] is outside array bounds "
"of %qT",
offrange[0].to_shwi (), offrange[1].to_shwi (), reftype);
@@ -5157,7 +5157,7 @@ vrp_prop::check_mem_ref (location_t location, tree
{
HOST_WIDE_INT tmpidx = extrema[i].to_shwi () / eltsize.to_shwi ();
- warning_at (location, OPT_Warray_bounds,
+ warning_at (location, OPT_Warray_bounds_,
"intermediate array offset %wi is outside array bounds "
"of %qT",
tmpidx, reftype);
@@ -5218,7 +5218,7 @@ vrp_prop::search_for_addr_array (tree t, location_
dump_generic_expr (MSG_NOTE, TDF_SLIM, t);
fprintf (dump_file, "\n");
}
- warning_at (location, OPT_Warray_bounds,
+ warning_at (location, OPT_Warray_bounds_,
"array subscript %wi is below array bounds of %qT",
idx.to_shwi (), TREE_TYPE (tem));
TREE_NO_WARNING (t) = 1;
@@ -5232,7 +5232,7 @@ vrp_prop::search_for_addr_array (tree t, location_
dump_generic_expr (MSG_NOTE, TDF_SLIM, t);
fprintf (dump_file, "\n");
}
- warning_at (location, OPT_Warray_bounds,
+ warning_at (location, OPT_Warray_bounds_,
"array subscript %wu is above array bounds of %qT",
idx.to_uhwi (), TREE_TYPE (tem));
TREE_NO_WARNING (t) = 1;