aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-array-bounds.cc
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2023-04-10 10:59:48 +0200
committerThomas Schwinge <thomas@codesourcery.com>2023-04-10 10:59:48 +0200
commit3757e8d71794cece4a5c9d08245b7ad111044853 (patch)
tree778c6eb8324fa714713ce30a0897e44cf276508b /gcc/gimple-array-bounds.cc
parente44f127cdb12a28536fe21983dfad20570bceda0 (diff)
parent6baa95c9c5b3fea96fd22d03d961db4e4cf48d88 (diff)
downloadgcc-3757e8d71794cece4a5c9d08245b7ad111044853.zip
gcc-3757e8d71794cece4a5c9d08245b7ad111044853.tar.gz
gcc-3757e8d71794cece4a5c9d08245b7ad111044853.tar.bz2
Merge commit '6baa95c9c5b3fea96fd22d03d961db4e4cf48d88' into HEAD [#2112]
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);