* [PATCH] Alias -Warray-bounds to -Warray-bounds=1
@ 2018-07-25 14:05 Franz Sirl
2018-07-31 20:58 ` Martin Sebor
0 siblings, 1 reply; 3+ messages in thread
From: Franz Sirl @ 2018-07-25 14:05 UTC (permalink / raw)
To: GCC Patches, Martin Sebor
[-- Attachment #1: Type: text/plain, Size: 190 bytes --]
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.
[-- Attachment #2: Warray-bounds-1.diff --]
[-- Type: text/plain, Size: 10198 bytes --]
gcc/ChangeLog:
2018-07-25 Franz Sirl <franz.sirl-kernel@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-kernel@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;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Alias -Warray-bounds to -Warray-bounds=1
2018-07-25 14:05 [PATCH] Alias -Warray-bounds to -Warray-bounds=1 Franz Sirl
@ 2018-07-31 20:58 ` Martin Sebor
2018-08-03 18:27 ` Jeff Law
0 siblings, 1 reply; 3+ messages in thread
From: Martin Sebor @ 2018-07-31 20:58 UTC (permalink / raw)
To: Franz Sirl, GCC Patches
I can't approve patches but this one seems to be in
the obvious category so I think it could be checked in
without formal approval.
It is however missing a couple of things: 1) a test case,
and 2) a reference to the bug it fixes in the ChangeLog
and in the test.
With that, if no one objects, I will commit the path for
you.
Martin
On 07/25/2018 08:04 AM, Franz Sirl wrote:
> 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.
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Alias -Warray-bounds to -Warray-bounds=1
2018-07-31 20:58 ` Martin Sebor
@ 2018-08-03 18:27 ` Jeff Law
0 siblings, 0 replies; 3+ messages in thread
From: Jeff Law @ 2018-08-03 18:27 UTC (permalink / raw)
To: Martin Sebor, Franz Sirl, GCC Patches
On 07/31/2018 02:58 PM, Martin Sebor wrote:
> I can't approve patches but this one seems to be in
> the obvious category so I think it could be checked in
> without formal approval.
>
> It is however missing a couple of things: 1) a test case,
> and 2) a reference to the bug it fixes in the ChangeLog
> and in the test.
>
> With that, if no one objects, I will commit the path for
> you.
I think the patch is fine. Go forward with it whenever it's convenient
for you.
jeff
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-08-03 18:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-25 14:05 [PATCH] Alias -Warray-bounds to -Warray-bounds=1 Franz Sirl
2018-07-31 20:58 ` Martin Sebor
2018-08-03 18:27 ` Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).