aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family/c-common.cc
diff options
context:
space:
mode:
authorIskander Shakirzyanov <iskander@ispras.ru>2022-11-24 14:26:59 +0000
committerAlexander Monakov <amonakov@ispras.ru>2022-11-30 16:30:48 +0300
commit7c01d029fca669263b9c2dcb8837c42f7ae3a77f (patch)
tree7990b3eae36ff8a67c01bc63050152b59ae671e3 /gcc/c-family/c-common.cc
parent4fa25a7eb322f0a003c1eb15680c71ece345e01e (diff)
downloadgcc-7c01d029fca669263b9c2dcb8837c42f7ae3a77f.zip
gcc-7c01d029fca669263b9c2dcb8837c42f7ae3a77f.tar.gz
gcc-7c01d029fca669263b9c2dcb8837c42f7ae3a77f.tar.bz2
Make Warray-bounds alias to Warray-bounds= [PR107787]
According to the documentation, the -Werror= option makes the specified warning into an error and also automatically implies that option. Then it seems that the behavior of the compiler when specifying -Werror=array-bounds=X should be the same as specifying "-Werror=array-bounds -Warray-bounds=X", so we expect to receive array-bounds pass diagnostics and they must be processed as errors. In practice, we observe that the array-bounds pass is indeed invoked, but its diagnostics are processed as warnings, not errors. This happens because Warray-bounds and Warray-bounds= are declared as two different options in common.opt, so when diagnostic_classify_diagnostic is called, DK_ERROR is set for the Warray-bounds= option, but diagnostic_report_diagnostic called from warning_at receives opt_index of Warray-bounds, so information about DK_ERROR is lost. Fix this by using Alias in declaration of Warray-bounds (similar to Wattribute-alias). Co-authored-by: Franz Sirl <Franz.Sirl-kernel@lauterbach.com> gcc/ChangeLog: PR driver/107787 * common.opt (Warray-bounds): Turn into alias of -Warray-bounds=1. * builtins.cc (c_strlen): Use OPT_Warray_bounds_ instead of OPT_Warray_bounds. * diagnostic-spec.cc (nowarn_spec_t::nowarn_spec_t): Ditto. * gimple-array-bounds.cc (array_bounds_checker::check_array_ref, array_bounds_checker::check_mem_ref, array_bounds_checker::check_addr_expr, array_bounds_checker::check_array_bounds): Ditto. * gimple-ssa-warn-restrict.cc (maybe_diag_access_bounds): Ditto. gcc/c-family/ChangeLog: PR driver/107787 * c-common.cc (fold_offsetof, convert_vector_to_array_for_subscript): Use OPT_Warray_bounds_ instead of OPT_Warray_bounds. gcc/testsuite/ChangeLog: PR driver/107787 * gcc.dg/Warray-bounds-34.c: Correct the regular expression for -Warray-bounds=. * gcc.dg/Warray-bounds-43.c: Likewise. * gcc.dg/pr107787.c: New test.
Diffstat (limited to 'gcc/c-family/c-common.cc')
-rw-r--r--gcc/c-family/c-common.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
index 6f1f21b..f08c891 100644
--- a/gcc/c-family/c-common.cc
+++ b/gcc/c-family/c-common.cc
@@ -6811,7 +6811,7 @@ fold_offsetof (tree expr, tree type, enum tree_code ctx)
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)));
@@ -8534,7 +8534,7 @@ convert_vector_to_array_for_subscript (location_t loc,
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