aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-array-bounds.cc
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2023-04-07 22:04:54 +0200
committerThomas Schwinge <thomas_schwinge@mentor.com>2023-04-07 22:04:54 +0200
commitb1d131f8941cd30ee7904698e7d3bcc20686b61c (patch)
tree3dcb318ea104daa2fcc771c5e3de080414c45730 /gcc/gimple-array-bounds.cc
parent353f5e8f00a2f897d2974f07d27dd10f79666889 (diff)
parent939fb3fffebf7be2638ddef25dbe1c15f2aaa9d6 (diff)
downloadgcc-b1d131f8941cd30ee7904698e7d3bcc20686b61c.zip
gcc-b1d131f8941cd30ee7904698e7d3bcc20686b61c.tar.gz
gcc-b1d131f8941cd30ee7904698e7d3bcc20686b61c.tar.bz2
Merge commit '939fb3fffebf7be2638ddef25dbe1c15f2aaa9d6' into HEAD
Diffstat (limited to 'gcc/gimple-array-bounds.cc')
-rw-r--r--gcc/gimple-array-bounds.cc41
1 files changed, 26 insertions, 15 deletions
diff --git a/gcc/gimple-array-bounds.cc b/gcc/gimple-array-bounds.cc
index 66fd46e..34e039a 100644
--- a/gcc/gimple-array-bounds.cc
+++ b/gcc/gimple-array-bounds.cc
@@ -397,27 +397,38 @@ array_bounds_checker::check_array_ref (location_t location, tree ref,
"of an interior zero-length array %qT")),
low_sub, artype);
- if (warned || out_of_bound)
+ if (warned && dump_file && (dump_flags & TDF_DETAILS))
{
- if (warned && dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, "Array bound warning for ");
+ dump_generic_expr (MSG_NOTE, TDF_SLIM, ref);
+ fprintf (dump_file, "\n");
+ }
+
+ /* Issue warnings for -Wstrict-flex-arrays according to the level of
+ flag_strict_flex_arrays. */
+ if (out_of_bound && warn_strict_flex_arrays
+ && (sam == special_array_member::trail_0
+ || sam == special_array_member::trail_1
+ || sam == special_array_member::trail_n)
+ && DECL_NOT_FLEXARRAY (afield_decl))
+ {
+ bool warned1
+ = warning_at (location, OPT_Wstrict_flex_arrays,
+ "trailing array %qT should not be used as "
+ "a flexible array member",
+ artype);
+
+ if (warned1 && dump_file && (dump_flags & TDF_DETAILS))
{
- fprintf (dump_file, "Array bound warning for ");
+ fprintf (dump_file, "Trailing non flexible-like array bound warning for ");
dump_generic_expr (MSG_NOTE, TDF_SLIM, ref);
fprintf (dump_file, "\n");
}
+ warned |= warned1;
+ }
- /* issue warnings for -Wstrict-flex-arrays according to the level of
- flag_strict_flex_arrays. */
- if ((out_of_bound && warn_strict_flex_arrays)
- && (((sam == special_array_member::trail_0)
- || (sam == special_array_member::trail_1)
- || (sam == special_array_member::trail_n))
- && DECL_NOT_FLEXARRAY (afield_decl)))
- warned = warning_at (location, OPT_Wstrict_flex_arrays,
- "trailing array %qT should not be used as "
- "a flexible array member",
- artype);
-
+ if (warned)
+ {
/* Avoid more warnings when checking more significant subscripts
of the same expression. */
ref = TREE_OPERAND (ref, 0);