Improve warning suppression for inlined functions.
Resolves:
PR middle-end/98871 - Cannot silence -Wmaybe-uninitialized at declaration site
PR middle-end/98512 - #pragma GCC diagnostic ignored ineffective in conjunction with alias attribute
gcc/ChangeLog:
* builtins.c (warn_string_no_nul): Remove %G.
(maybe_warn_for_bound): Same.
(warn_for_access): Same.
(check_access): Same.
(check_strncat_sizes): Same.
(expand_builtin_strncat): Same.
(expand_builtin_strncmp): Same.
(expand_builtin): Same.
(expand_builtin_object_size): Same.
(warn_dealloc_offset): Same.
(maybe_emit_free_warning): Same.
* calls.c (maybe_warn_alloc_args_overflow): Same.
(maybe_warn_nonstring_arg): Same.
(maybe_warn_rdwr_sizes): Same.
* expr.c (expand_expr_real_1): Remove %K.
* gimple-fold.c (gimple_fold_builtin_strncpy): Remove %G.
(gimple_fold_builtin_strncat): Same.
* gimple-ssa-sprintf.c (format_directive): Same.
(handle_printf_call): Same.
* gimple-ssa-warn-alloca.c (pass_walloca::execute): Same.
* gimple-ssa-warn-restrict.c (maybe_diag_overlap): Same.
(maybe_diag_access_bounds): Same. Call gimple_location.
(check_bounds_or_overlap): Same.
* trans-mem.c (ipa_tm_scan_irr_block): Remove %K. Simplify.
* tree-ssa-ccp.c (pass_post_ipa_warn::execute): Remove %G.
* tree-ssa-strlen.c (maybe_warn_overflow): Same.
(maybe_diag_stxncpy_trunc): Same.
(handle_builtin_stxncpy_strncat): Same.
(maybe_warn_pointless_strcmp): Same.
* tree-ssa-uninit.c (maybe_warn_operand): Same.
gcc/testsuite/ChangeLog:
* gcc.dg/Wfree-nonheap-object-4.c: Tighten up.
* gcc.dg/Wobjsize-1.c: Prune expected output.
* gcc.dg/Warray-bounds-71.c: New test.
* gcc.dg/Warray-bounds-71.h: New test.
* gcc.dg/Warray-bounds-72.c: New test.
* gcc.dg/Warray-bounds-73.c: New test.
* gcc.dg/Warray-bounds-74.c: New test.
* gcc.dg/Warray-bounds-75.c: New test.
* gcc.dg/Wfree-nonheap-object-5.c: New test.
* gcc.dg/pragma-diag-10.c: New test.
* gcc.dg/pragma-diag-9.c: New test.
* gcc.dg/uninit-suppress_3.c: New test.
@@ -1124,30 +1124,30 @@ warn_string_no_nul (location_t loc, tree expr, const char *fname,
{
if (wi::ltu_p (maxsiz, bndrng[0]))
warned = warning_at (loc, OPT_Wstringop_overread,
- "%K%qD specified bound %s exceeds "
+ "%qD specified bound %s exceeds "
"maximum object size %E",
- expr, func, bndstr, maxobjsize);
+ func, bndstr, maxobjsize);
else
{
bool maybe = wi::to_wide (size) == bndrng[0];
warned = warning_at (loc, OPT_Wstringop_overread,
exact
- ? G_("%K%qD specified bound %s exceeds "
+ ? G_("%qD specified bound %s exceeds "
"the size %E of unterminated array")
: (maybe
- ? G_("%K%qD specified bound %s may "
+ ? G_("%qD specified bound %s may "
"exceed the size of at most %E "
"of unterminated array")
- : G_("%K%qD specified bound %s exceeds "
+ : G_("%qD specified bound %s exceeds "
"the size of at most %E "
"of unterminated array")),
- expr, func, bndstr, size);
+ func, bndstr, size);
}
}
else
warned = warning_at (loc, OPT_Wstringop_overread,
- "%K%qD argument missing terminating nul",
- expr, func);
+ "%qD argument missing terminating nul",
+ func);
}
else
{
@@ -3967,35 +3967,34 @@ maybe_warn_for_bound (int opt, location_t loc, tree exp, tree func,
warned = (func
? warning_at (loc, opt,
(maybe
- ? G_("%K%qD specified bound %E may "
+ ? G_("%qD specified bound %E may "
"exceed maximum object size %E")
- : G_("%K%qD specified bound %E "
+ : G_("%qD specified bound %E "
"exceeds maximum object size %E")),
- exp, func, bndrng[0], maxobjsize)
+ func, bndrng[0], maxobjsize)
: warning_at (loc, opt,
(maybe
- ? G_("%Kspecified bound %E may "
+ ? G_("specified bound %E may "
"exceed maximum object size %E")
- : G_("%Kspecified bound %E "
+ : G_("specified bound %E "
"exceeds maximum object size %E")),
- exp, bndrng[0], maxobjsize));
+ bndrng[0], maxobjsize));
else
warned = (func
? warning_at (loc, opt,
(maybe
- ? G_("%K%qD specified bound [%E, %E] may "
+ ? G_("%qD specified bound [%E, %E] may "
"exceed maximum object size %E")
- : G_("%K%qD specified bound [%E, %E] "
+ : G_("%qD specified bound [%E, %E] "
"exceeds maximum object size %E")),
- exp, func,
- bndrng[0], bndrng[1], maxobjsize)
+ func, bndrng[0], bndrng[1], maxobjsize)
: warning_at (loc, opt,
(maybe
- ? G_("%Kspecified bound [%E, %E] may "
+ ? G_("specified bound [%E, %E] may "
"exceed maximum object size %E")
- : G_("%Kspecified bound [%E, %E] "
+ : G_("specified bound [%E, %E] "
"exceeds maximum object size %E")),
- exp, bndrng[0], bndrng[1], maxobjsize));
+ bndrng[0], bndrng[1], maxobjsize));
}
else if (!size || tree_int_cst_le (bndrng[0], size))
return false;
@@ -4003,34 +4002,34 @@ maybe_warn_for_bound (int opt, location_t loc, tree exp, tree func,
warned = (func
? warning_at (loc, opt,
(maybe
- ? G_("%K%qD specified bound %E may exceed "
+ ? G_("%qD specified bound %E may exceed "
"source size %E")
- : G_("%K%qD specified bound %E exceeds "
+ : G_("%qD specified bound %E exceeds "
"source size %E")),
- exp, func, bndrng[0], size)
+ func, bndrng[0], size)
: warning_at (loc, opt,
(maybe
- ? G_("%Kspecified bound %E may exceed "
+ ? G_("specified bound %E may exceed "
"source size %E")
- : G_("%Kspecified bound %E exceeds "
+ : G_("specified bound %E exceeds "
"source size %E")),
- exp, bndrng[0], size));
+ bndrng[0], size));
else
warned = (func
? warning_at (loc, opt,
(maybe
- ? G_("%K%qD specified bound [%E, %E] may "
+ ? G_("%qD specified bound [%E, %E] may "
"exceed source size %E")
- : G_("%K%qD specified bound [%E, %E] exceeds "
+ : G_("%qD specified bound [%E, %E] exceeds "
"source size %E")),
- exp, func, bndrng[0], bndrng[1], size)
+ func, bndrng[0], bndrng[1], size)
: warning_at (loc, opt,
(maybe
- ? G_("%Kspecified bound [%E, %E] may exceed "
+ ? G_("specified bound [%E, %E] may exceed "
"source size %E")
- : G_("%Kspecified bound [%E, %E] exceeds "
+ : G_("specified bound [%E, %E] exceeds "
"source size %E")),
- exp, bndrng[0], bndrng[1], size));
+ bndrng[0], bndrng[1], size));
if (warned)
{
if (pad && pad->src.ref)
@@ -4055,35 +4054,34 @@ maybe_warn_for_bound (int opt, location_t loc, tree exp, tree func,
warned = (func
? warning_at (loc, opt,
(maybe
- ? G_("%K%qD specified size %E may "
+ ? G_("%qD specified size %E may "
"exceed maximum object size %E")
- : G_("%K%qD specified size %E "
+ : G_("%qD specified size %E "
"exceeds maximum object size %E")),
- exp, func, bndrng[0], maxobjsize)
+ func, bndrng[0], maxobjsize)
: warning_at (loc, opt,
(maybe
- ? G_("%Kspecified size %E may exceed "
+ ? G_("specified size %E may exceed "
"maximum object size %E")
- : G_("%Kspecified size %E exceeds "
+ : G_("specified size %E exceeds "
"maximum object size %E")),
- exp, bndrng[0], maxobjsize));
+ bndrng[0], maxobjsize));
else
warned = (func
? warning_at (loc, opt,
(maybe
- ? G_("%K%qD specified size between %E and %E "
+ ? G_("%qD specified size between %E and %E "
"may exceed maximum object size %E")
- : G_("%K%qD specified size between %E and %E "
+ : G_("%qD specified size between %E and %E "
"exceeds maximum object size %E")),
- exp, func,
- bndrng[0], bndrng[1], maxobjsize)
+ func, bndrng[0], bndrng[1], maxobjsize)
: warning_at (loc, opt,
(maybe
- ? G_("%Kspecified size between %E and %E "
+ ? G_("specified size between %E and %E "
"may exceed maximum object size %E")
- : G_("%Kspecified size between %E and %E "
+ : G_("specified size between %E and %E "
"exceeds maximum object size %E")),
- exp, bndrng[0], bndrng[1], maxobjsize));
+ bndrng[0], bndrng[1], maxobjsize));
}
else if (!size || tree_int_cst_le (bndrng[0], size))
return false;
@@ -4091,34 +4089,34 @@ maybe_warn_for_bound (int opt, location_t loc, tree exp, tree func,
warned = (func
? warning_at (loc, OPT_Wstringop_overflow_,
(maybe
- ? G_("%K%qD specified bound %E may exceed "
+ ? G_("%qD specified bound %E may exceed "
"destination size %E")
- : G_("%K%qD specified bound %E exceeds "
+ : G_("%qD specified bound %E exceeds "
"destination size %E")),
- exp, func, bndrng[0], size)
+ func, bndrng[0], size)
: warning_at (loc, OPT_Wstringop_overflow_,
(maybe
- ? G_("%Kspecified bound %E may exceed "
+ ? G_("specified bound %E may exceed "
"destination size %E")
- : G_("%Kspecified bound %E exceeds "
+ : G_("specified bound %E exceeds "
"destination size %E")),
- exp, bndrng[0], size));
+ bndrng[0], size));
else
warned = (func
? warning_at (loc, OPT_Wstringop_overflow_,
(maybe
- ? G_("%K%qD specified bound [%E, %E] may exceed "
+ ? G_("%qD specified bound [%E, %E] may exceed "
"destination size %E")
- : G_("%K%qD specified bound [%E, %E] exceeds "
+ : G_("%qD specified bound [%E, %E] exceeds "
"destination size %E")),
- exp, func, bndrng[0], bndrng[1], size)
+ func, bndrng[0], bndrng[1], size)
: warning_at (loc, OPT_Wstringop_overflow_,
(maybe
- ? G_("%Kspecified bound [%E, %E] exceeds "
+ ? G_("specified bound [%E, %E] exceeds "
"destination size %E")
- : G_("%Kspecified bound [%E, %E] exceeds "
+ : G_("specified bound [%E, %E] exceeds "
"destination size %E")),
- exp, bndrng[0], bndrng[1], size));
+ bndrng[0], bndrng[1], size));
if (warned)
{
@@ -4156,65 +4154,63 @@ warn_for_access (location_t loc, tree func, tree exp, int opt, tree range[2],
warned = (func
? warning_n (loc, opt, tree_to_uhwi (range[0]),
(maybe
- ? G_("%K%qD may access %E byte in a region "
+ ? G_("%qD may access %E byte in a region "
"of size %E")
- : G_("%K%qD accessing %E byte in a region "
+ : G_("%qD accessing %E byte in a region "
"of size %E")),
(maybe
- ? G_ ("%K%qD may access %E bytes in a region "
+ ? G_ ("%qD may access %E bytes in a region "
"of size %E")
- : G_ ("%K%qD accessing %E bytes in a region "
+ : G_ ("%qD accessing %E bytes in a region "
"of size %E")),
- exp, func, range[0], size)
+ func, range[0], size)
: warning_n (loc, opt, tree_to_uhwi (range[0]),
(maybe
- ? G_("%Kmay access %E byte in a region "
+ ? G_("may access %E byte in a region "
"of size %E")
- : G_("%Kaccessing %E byte in a region "
+ : G_("accessing %E byte in a region "
"of size %E")),
(maybe
- ? G_("%Kmay access %E bytes in a region "
+ ? G_("may access %E bytes in a region "
"of size %E")
- : G_("%Kaccessing %E bytes in a region "
+ : G_("accessing %E bytes in a region "
"of size %E")),
- exp, range[0], size));
+ range[0], size));
else if (tree_int_cst_sign_bit (range[1]))
{
/* Avoid printing the upper bound if it's invalid. */
warned = (func
? warning_at (loc, opt,
(maybe
- ? G_("%K%qD may access %E or more bytes "
+ ? G_("%qD may access %E or more bytes "
"in a region of size %E")
- : G_("%K%qD accessing %E or more bytes "
+ : G_("%qD accessing %E or more bytes "
"in a region of size %E")),
- exp, func, range[0], size)
+ func, range[0], size)
: warning_at (loc, opt,
(maybe
- ? G_("%Kmay access %E or more bytes "
+ ? G_("may access %E or more bytes "
"in a region of size %E")
- : G_("%Kaccessing %E or more bytes "
+ : G_("accessing %E or more bytes "
"in a region of size %E")),
- exp, range[0], size));
+ range[0], size));
}
else
warned = (func
? warning_at (loc, opt,
(maybe
- ? G_("%K%qD may access between %E and %E "
+ ? G_("%qD may access between %E and %E "
"bytes in a region of size %E")
- : G_("%K%qD accessing between %E and %E "
+ : G_("%qD accessing between %E and %E "
"bytes in a region of size %E")),
- exp, func, range[0], range[1],
- size)
+ func, range[0], range[1], size)
: warning_at (loc, opt,
(maybe
- ? G_("%Kmay access between %E and %E bytes "
+ ? G_("may access between %E and %E bytes "
"in a region of size %E")
- : G_("%Kaccessing between %E and %E bytes "
+ : G_("accessing between %E and %E bytes "
"in a region of size %E")),
- exp, range[0], range[1],
- size));
+ range[0], range[1], size));
return warned;
}
@@ -4224,69 +4220,67 @@ warn_for_access (location_t loc, tree func, tree exp, int opt, tree range[2],
warned = (func
? warning_n (loc, opt, tree_to_uhwi (range[0]),
(maybe
- ? G_("%K%qD may write %E byte into a region "
+ ? G_("%qD may write %E byte into a region "
"of size %E")
- : G_("%K%qD writing %E byte into a region "
+ : G_("%qD writing %E byte into a region "
"of size %E overflows the destination")),
(maybe
- ? G_("%K%qD may write %E bytes into a region "
+ ? G_("%qD may write %E bytes into a region "
"of size %E")
- : G_("%K%qD writing %E bytes into a region "
+ : G_("%qD writing %E bytes into a region "
"of size %E overflows the destination")),
- exp, func, range[0], size)
+ func, range[0], size)
: warning_n (loc, opt, tree_to_uhwi (range[0]),
(maybe
- ? G_("%Kmay write %E byte into a region "
+ ? G_("may write %E byte into a region "
"of size %E")
- : G_("%Kwriting %E byte into a region "
+ : G_("writing %E byte into a region "
"of size %E overflows the destination")),
(maybe
- ? G_("%Kmay write %E bytes into a region "
+ ? G_("may write %E bytes into a region "
"of size %E")
- : G_("%Kwriting %E bytes into a region "
+ : G_("writing %E bytes into a region "
"of size %E overflows the destination")),
- exp, range[0], size));
+ range[0], size));
else if (tree_int_cst_sign_bit (range[1]))
{
/* Avoid printing the upper bound if it's invalid. */
warned = (func
? warning_at (loc, opt,
(maybe
- ? G_("%K%qD may write %E or more bytes "
+ ? G_("%qD may write %E or more bytes "
"into a region of size %E")
- : G_("%K%qD writing %E or more bytes "
+ : G_("%qD writing %E or more bytes "
"into a region of size %E overflows "
"the destination")),
- exp, func, range[0], size)
+ func, range[0], size)
: warning_at (loc, opt,
(maybe
- ? G_("%Kmay write %E or more bytes into "
+ ? G_("may write %E or more bytes into "
"a region of size %E")
- : G_("%Kwriting %E or more bytes into "
+ : G_("writing %E or more bytes into "
"a region of size %E overflows "
"the destination")),
- exp, range[0], size));
+ range[0], size));
}
else
warned = (func
? warning_at (loc, opt,
(maybe
- ? G_("%K%qD may write between %E and %E bytes "
+ ? G_("%qD may write between %E and %E bytes "
"into a region of size %E")
- : G_("%K%qD writing between %E and %E bytes "
+ : G_("%qD writing between %E and %E bytes "
"into a region of size %E overflows "
"the destination")),
- exp, func, range[0], range[1],
- size)
+ func, range[0], range[1], size)
: warning_at (loc, opt,
(maybe
- ? G_("%Kmay write between %E and %E bytes "
+ ? G_("may write between %E and %E bytes "
"into a region of size %E")
- : G_("%Kwriting between %E and %E bytes "
+ : G_("writing between %E and %E bytes "
"into a region of size %E overflows "
"the destination")),
- exp, range[0], range[1],
- size));
+ range[0], range[1], size));
return warned;
}
@@ -4297,64 +4291,64 @@ warn_for_access (location_t loc, tree func, tree exp, int opt, tree range[2],
? warning_n (loc, OPT_Wstringop_overread,
tree_to_uhwi (range[0]),
(maybe
- ? G_("%K%qD may read %E byte from a region "
+ ? G_("%qD may read %E byte from a region "
"of size %E")
- : G_("%K%qD reading %E byte from a region "
+ : G_("%qD reading %E byte from a region "
"of size %E")),
(maybe
- ? G_("%K%qD may read %E bytes from a region "
+ ? G_("%qD may read %E bytes from a region "
"of size %E")
- : G_("%K%qD reading %E bytes from a region "
+ : G_("%qD reading %E bytes from a region "
"of size %E")),
- exp, func, range[0], size)
+ func, range[0], size)
: warning_n (loc, OPT_Wstringop_overread,
tree_to_uhwi (range[0]),
(maybe
- ? G_("%Kmay read %E byte from a region "
+ ? G_("may read %E byte from a region "
"of size %E")
- : G_("%Kreading %E byte from a region "
+ : G_("reading %E byte from a region "
"of size %E")),
(maybe
- ? G_("%Kmay read %E bytes from a region "
+ ? G_("may read %E bytes from a region "
"of size %E")
- : G_("%Kreading %E bytes from a region "
+ : G_("reading %E bytes from a region "
"of size %E")),
- exp, range[0], size));
+ range[0], size));
else if (tree_int_cst_sign_bit (range[1]))
{
/* Avoid printing the upper bound if it's invalid. */
warned = (func
? warning_at (loc, OPT_Wstringop_overread,
(maybe
- ? G_("%K%qD may read %E or more bytes "
+ ? G_("%qD may read %E or more bytes "
"from a region of size %E")
- : G_("%K%qD reading %E or more bytes "
+ : G_("%qD reading %E or more bytes "
"from a region of size %E")),
- exp, func, range[0], size)
+ func, range[0], size)
: warning_at (loc, OPT_Wstringop_overread,
(maybe
- ? G_("%Kmay read %E or more bytes "
+ ? G_("may read %E or more bytes "
"from a region of size %E")
- : G_("%Kreading %E or more bytes "
+ : G_("reading %E or more bytes "
"from a region of size %E")),
- exp, range[0], size));
+ range[0], size));
}
else
warned = (func
? warning_at (loc, OPT_Wstringop_overread,
(maybe
- ? G_("%K%qD may read between %E and %E bytes "
+ ? G_("%qD may read between %E and %E bytes "
"from a region of size %E")
- : G_("%K%qD reading between %E and %E bytes "
+ : G_("%qD reading between %E and %E bytes "
"from a region of size %E")),
- exp, func, range[0], range[1], size)
+ func, range[0], range[1], size)
: warning_at (loc, opt,
(maybe
- ? G_("%Kmay read between %E and %E bytes "
+ ? G_("may read between %E and %E bytes "
"from a region of size %E")
- : G_("%Kreading between %E and %E bytes "
+ : G_("reading between %E and %E bytes "
"from a region of size %E")),
- exp, range[0], range[1], size));
+ range[0], range[1], size));
if (warned)
TREE_NO_WARNING (exp) = true;
@@ -4367,37 +4361,37 @@ warn_for_access (location_t loc, tree func, tree exp, int opt, tree range[2],
warned = (func
? warning_n (loc, OPT_Wstringop_overread,
tree_to_uhwi (range[0]),
- "%K%qD expecting %E byte in a region of size %E",
- "%K%qD expecting %E bytes in a region of size %E",
- exp, func, range[0], size)
+ "%qD expecting %E byte in a region of size %E",
+ "%qD expecting %E bytes in a region of size %E",
+ func, range[0], size)
: warning_n (loc, OPT_Wstringop_overread,
tree_to_uhwi (range[0]),
- "%Kexpecting %E byte in a region of size %E",
- "%Kexpecting %E bytes in a region of size %E",
- exp, range[0], size));
+ "expecting %E byte in a region of size %E",
+ "expecting %E bytes in a region of size %E",
+ range[0], size));
else if (tree_int_cst_sign_bit (range[1]))
{
/* Avoid printing the upper bound if it's invalid. */
warned = (func
? warning_at (loc, OPT_Wstringop_overread,
- "%K%qD expecting %E or more bytes in a region "
+ "%qD expecting %E or more bytes in a region "
"of size %E",
- exp, func, range[0], size)
+ func, range[0], size)
: warning_at (loc, OPT_Wstringop_overread,
- "%Kexpecting %E or more bytes in a region "
+ "expecting %E or more bytes in a region "
"of size %E",
- exp, range[0], size));
+ range[0], size));
}
else
warned = (func
? warning_at (loc, OPT_Wstringop_overread,
- "%K%qD expecting between %E and %E bytes in "
+ "%qD expecting between %E and %E bytes in "
"a region of size %E",
- exp, func, range[0], range[1], size)
+ func, range[0], range[1], size)
: warning_at (loc, OPT_Wstringop_overread,
- "%Kexpecting between %E and %E bytes in "
+ "expecting between %E and %E bytes in "
"a region of size %E",
- exp, range[0], range[1], size));
+ range[0], range[1], size));
if (warned)
TREE_NO_WARNING (exp) = true;
@@ -4757,7 +4751,7 @@ check_access (tree exp, tree dstwrite,
&& TREE_CODE (range[0]) == INTEGER_CST
&& tree_int_cst_lt (maxobjsize, range[0]))
{
- location_t loc = tree_inlined_location (exp);
+ location_t loc = EXPR_LOCATION (exp);
maybe_warn_for_bound (OPT_Wstringop_overflow_, loc, exp, func, range,
NULL_TREE, pad);
return false;
@@ -4783,7 +4777,7 @@ check_access (tree exp, tree dstwrite,
|| (pad && pad->dst.ref && TREE_NO_WARNING (pad->dst.ref)))
return false;
- location_t loc = tree_inlined_location (exp);
+ location_t loc = EXPR_LOCATION (exp);
bool warned = false;
if (dstwrite == slen && at_least_one)
{
@@ -4792,15 +4786,15 @@ check_access (tree exp, tree dstwrite,
at least one byte past the end of the destination. */
warned = (func
? warning_at (loc, OPT_Wstringop_overflow_,
- "%K%qD writing %E or more bytes into "
+ "%qD writing %E or more bytes into "
"a region of size %E overflows "
"the destination",
- exp, func, range[0], dstsize)
+ func, range[0], dstsize)
: warning_at (loc, OPT_Wstringop_overflow_,
- "%Kwriting %E or more bytes into "
+ "writing %E or more bytes into "
"a region of size %E overflows "
"the destination",
- exp, range[0], dstsize));
+ range[0], dstsize));
}
else
{
@@ -4836,7 +4830,7 @@ check_access (tree exp, tree dstwrite,
PAD is nonnull and BNDRNG is valid. */
get_size_range (maxread, range, pad ? pad->src.bndrng : NULL);
- location_t loc = tree_inlined_location (exp);
+ location_t loc = EXPR_LOCATION (exp);
tree size = dstsize;
if (pad && pad->mode == access_read_only)
size = wide_int_to_tree (sizetype, pad->src.sizrng[1]);
@@ -4895,7 +4889,7 @@ check_access (tree exp, tree dstwrite,
|| (pad && pad->src.ref && TREE_NO_WARNING (pad->src.ref)))
return false;
- location_t loc = tree_inlined_location (exp);
+ location_t loc = EXPR_LOCATION (exp);
const bool read
= mode == access_read_only || mode == access_read_write;
const bool maybe = pad && pad->dst.parmarray;
@@ -6440,10 +6434,10 @@ check_strncat_sizes (tree exp, tree objsize)
if (tree_fits_uhwi_p (maxread) && tree_fits_uhwi_p (objsize)
&& tree_int_cst_equal (objsize, maxread))
{
- location_t loc = tree_inlined_location (exp);
+ location_t loc = EXPR_LOCATION (exp);
warning_at (loc, OPT_Wstringop_overflow_,
- "%K%qD specified bound %E equals destination size",
- exp, get_callee_fndecl (exp), maxread);
+ "%qD specified bound %E equals destination size",
+ get_callee_fndecl (exp), maxread);
return false;
}
@@ -6513,10 +6507,10 @@ expand_builtin_strncat (tree exp, rtx)
if (tree_fits_uhwi_p (maxread) && tree_fits_uhwi_p (destsize)
&& tree_int_cst_equal (destsize, maxread))
{
- location_t loc = tree_inlined_location (exp);
+ location_t loc = EXPR_LOCATION (exp);
warning_at (loc, OPT_Wstringop_overflow_,
- "%K%qD specified bound %E equals destination size",
- exp, get_callee_fndecl (exp), maxread);
+ "%qD specified bound %E equals destination size",
+ get_callee_fndecl (exp), maxread);
return NULL_RTX;
}
@@ -7289,7 +7283,7 @@ expand_builtin_strncmp (tree exp, ATTRIBUTE_UNUSED rtx target,
|| !check_nul_terminated_array (exp, arg2, arg3))
return NULL_RTX;
- location_t loc = tree_inlined_location (exp);
+ location_t loc = EXPR_LOCATION (exp);
tree len1 = c_strlen (arg1, 1);
tree len2 = c_strlen (arg2, 1);
@@ -9966,13 +9960,13 @@ expand_builtin (tree exp, rtx target, rtx subtarget, machine_mode mode,
case BUILT_IN_VA_ARG_PACK:
/* All valid uses of __builtin_va_arg_pack () are removed during
inlining. */
- error ("%Kinvalid use of %<__builtin_va_arg_pack ()%>", exp);
+ error ("invalid use of %<__builtin_va_arg_pack ()%>");
return const0_rtx;
case BUILT_IN_VA_ARG_PACK_LEN:
/* All valid uses of __builtin_va_arg_pack_len () are removed during
inlining. */
- error ("%Kinvalid use of %<__builtin_va_arg_pack_len ()%>", exp);
+ error ("invalid use of %<__builtin_va_arg_pack_len ()%>");
return const0_rtx;
/* Return the address of the first anonymous stack arg. */
@@ -12921,8 +12915,8 @@ expand_builtin_object_size (tree exp)
if (!validate_arglist (exp, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE))
{
- error ("%Kfirst argument of %qD must be a pointer, second integer constant",
- exp, fndecl);
+ error ("first argument of %qD must be a pointer, second integer constant",
+ fndecl);
expand_builtin_trap ();
return const0_rtx;
}
@@ -12934,8 +12928,8 @@ expand_builtin_object_size (tree exp)
|| tree_int_cst_sgn (ost) < 0
|| compare_tree_int (ost, 3) > 0)
{
- error ("%Klast argument of %qD is not integer constant between 0 and 3",
- exp, fndecl);
+ error ("last argument of %qD is not integer constant between 0 and 3",
+ fndecl);
expand_builtin_trap ();
return const0_rtx;
}
@@ -13737,8 +13731,8 @@ warn_dealloc_offset (location_t loc, tree exp, const access_ref &aref)
}
if (!warning_at (loc, OPT_Wfree_nonheap_object,
- "%K%qD called on pointer %qE with nonzero offset%s",
- exp, dealloc_decl, aref.ref, offstr))
+ "%qD called on pointer %qE with nonzero offset%s",
+ dealloc_decl, aref.ref, offstr))
return false;
if (DECL_P (aref.ref))
@@ -13793,15 +13787,15 @@ maybe_emit_free_warning (tree exp)
return;
tree dealloc_decl = get_callee_fndecl (exp);
- location_t loc = tree_inlined_location (exp);
+ location_t loc = EXPR_LOCATION (exp);
if (DECL_P (ref) || EXPR_P (ref))
{
/* Diagnose freeing a declared object. */
if (aref.ref_declared ()
&& warning_at (loc, OPT_Wfree_nonheap_object,
- "%K%qD called on unallocated object %qD",
- exp, dealloc_decl, ref))
+ "%qD called on unallocated object %qD",
+ dealloc_decl, ref))
{
loc = (DECL_P (ref)
? DECL_SOURCE_LOCATION (ref)
@@ -13820,8 +13814,8 @@ maybe_emit_free_warning (tree exp)
else if (CONSTANT_CLASS_P (ref))
{
if (warning_at (loc, OPT_Wfree_nonheap_object,
- "%K%qD called on a pointer to an unallocated "
- "object %qE", exp, dealloc_decl, ref))
+ "%qD called on a pointer to an unallocated "
+ "object %qE", dealloc_decl, ref))
{
if (TREE_CODE (ptr) == SSA_NAME)
{
@@ -13858,18 +13852,18 @@ maybe_emit_free_warning (tree exp)
? OPT_Wmismatched_new_delete
: OPT_Wmismatched_dealloc);
warned = warning_at (loc, opt,
- "%K%qD called on pointer returned "
+ "%qD called on pointer returned "
"from a mismatched allocation "
- "function", exp, dealloc_decl);
+ "function", dealloc_decl);
}
}
else if (gimple_call_builtin_p (def_stmt, BUILT_IN_ALLOCA)
|| gimple_call_builtin_p (def_stmt,
BUILT_IN_ALLOCA_WITH_ALIGN))
warned = warning_at (loc, OPT_Wfree_nonheap_object,
- "%K%qD called on pointer to "
+ "%qD called on pointer to "
"an unallocated object",
- exp, dealloc_decl);
+ dealloc_decl);
else if (warn_dealloc_offset (loc, exp, aref))
return;
@@ -1435,8 +1435,8 @@ maybe_warn_alloc_args_overflow (tree fn, tree exp, tree args[2], int idx[2])
if (tree_int_cst_lt (args[i], integer_zero_node))
{
warned = warning_at (loc, OPT_Walloc_size_larger_than_,
- "%Kargument %i value %qE is negative",
- exp, idx[i] + 1, args[i]);
+ "argument %i value %qE is negative",
+ idx[i] + 1, args[i]);
}
else if (integer_zerop (args[i]))
{
@@ -1452,8 +1452,8 @@ maybe_warn_alloc_args_overflow (tree fn, tree exp, tree args[2], int idx[2])
: !lookup_attribute ("returns_nonnull",
TYPE_ATTRIBUTES (fntype)))
warned = warning_at (loc, OPT_Walloc_zero,
- "%Kargument %i value is zero",
- exp, idx[i] + 1);
+ "argument %i value is zero",
+ idx[i] + 1);
}
else if (tree_int_cst_lt (maxobjsize, args[i]))
{
@@ -1470,9 +1470,9 @@ maybe_warn_alloc_args_overflow (tree fn, tree exp, tree args[2], int idx[2])
continue;
warned = warning_at (loc, OPT_Walloc_size_larger_than_,
- "%Kargument %i value %qE exceeds "
+ "argument %i value %qE exceeds "
"maximum object size %E",
- exp, idx[i] + 1, args[i], maxobjsize);
+ idx[i] + 1, args[i], maxobjsize);
}
}
else if (TREE_CODE (args[i]) == SSA_NAME
@@ -1484,16 +1484,16 @@ maybe_warn_alloc_args_overflow (tree fn, tree exp, tree args[2], int idx[2])
&& tree_int_cst_le (argrange[i][1], integer_zero_node))
{
warned = warning_at (loc, OPT_Walloc_size_larger_than_,
- "%Kargument %i range [%E, %E] is negative",
- exp, idx[i] + 1,
+ "argument %i range [%E, %E] is negative",
+ idx[i] + 1,
argrange[i][0], argrange[i][1]);
}
else if (tree_int_cst_lt (maxobjsize, argrange[i][0]))
{
warned = warning_at (loc, OPT_Walloc_size_larger_than_,
- "%Kargument %i range [%E, %E] exceeds "
+ "argument %i range [%E, %E] exceeds "
"maximum object size %E",
- exp, idx[i] + 1,
+ idx[i] + 1,
argrange[i][0], argrange[i][1],
maxobjsize);
}
@@ -1521,15 +1521,15 @@ maybe_warn_alloc_args_overflow (tree fn, tree exp, tree args[2], int idx[2])
if (vflow)
warned = warning_at (loc, OPT_Walloc_size_larger_than_,
- "%Kproduct %<%E * %E%> of arguments %i and %i "
+ "product %<%E * %E%> of arguments %i and %i "
"exceeds %<SIZE_MAX%>",
- exp, argrange[0][0], argrange[1][0],
+ argrange[0][0], argrange[1][0],
idx[0] + 1, idx[1] + 1);
else if (wi::ltu_p (wi::to_wide (maxobjsize, szprec), prod))
warned = warning_at (loc, OPT_Walloc_size_larger_than_,
- "%Kproduct %<%E * %E%> of arguments %i and %i "
+ "product %<%E * %E%> of arguments %i and %i "
"exceeds maximum object size %E",
- exp, argrange[0][0], argrange[1][0],
+ argrange[0][0], argrange[1][0],
idx[0] + 1, idx[1] + 1,
maxobjsize);
@@ -1729,14 +1729,14 @@ maybe_warn_nonstring_arg (tree fndecl, tree exp)
bool warned = false;
if (tree_int_cst_equal (bndrng[0], bndrng[1]))
warned = warning_at (loc, OPT_Wstringop_overread,
- "%K%qD specified bound %E "
+ "%qD specified bound %E "
"exceeds maximum object size %E",
- exp, fndecl, bndrng[0], maxobjsize);
+ fndecl, bndrng[0], maxobjsize);
else
warned = warning_at (loc, OPT_Wstringop_overread,
- "%K%qD specified bound [%E, %E] "
+ "%qD specified bound [%E, %E] "
"exceeds maximum object size %E",
- exp, fndecl, bndrng[0], bndrng[1],
+ fndecl, bndrng[0], bndrng[1],
maxobjsize);
if (warned)
TREE_NO_WARNING (exp) = true;
@@ -2068,16 +2068,16 @@ maybe_warn_rdwr_sizes (rdwr_map *rwm, tree fndecl, tree fntype, tree exp)
= access.second.array_as_string (ptrtype);
arg_warned = warning_at (loc, OPT_Wstringop_overflow_,
- "%Kbound argument %i value %s is "
+ "bound argument %i value %s is "
"negative for a variable length array "
"argument %i of type %s",
- exp, sizidx + 1, sizstr,
+ sizidx + 1, sizstr,
ptridx + 1, argtypestr.c_str ());
}
else
arg_warned = warning_at (loc, OPT_Wstringop_overflow_,
- "%Kargument %i value %s is negative",
- exp, sizidx + 1, sizstr);
+ "argument %i value %s is negative",
+ sizidx + 1, sizstr);
if (arg_warned)
{
@@ -2123,19 +2123,19 @@ maybe_warn_rdwr_sizes (rdwr_map *rwm, tree fndecl, tree fntype, tree exp)
= access.second.array_as_string (ptrtype);
arg_warned = warning_at (loc, OPT_Wnonnull,
- "%Kargument %i of variable length "
+ "argument %i of variable length "
"array %s is null but "
"the corresponding bound argument "
"%i value is %s",
- exp, sizidx + 1, argtypestr.c_str (),
+ sizidx + 1, argtypestr.c_str (),
ptridx + 1, sizstr);
}
else
arg_warned = warning_at (loc, OPT_Wnonnull,
- "%Kargument %i is null but "
+ "argument %i is null but "
"the corresponding size argument "
"%i value is %s",
- exp, ptridx + 1, sizidx + 1,
+ ptridx + 1, sizidx + 1,
sizstr);
}
else if (access_size && access.second.static_p)
@@ -2143,9 +2143,9 @@ maybe_warn_rdwr_sizes (rdwr_map *rwm, tree fndecl, tree fntype, tree exp)
/* Warn about null pointers for [static N] array arguments
but do not warn for ordinary (i.e., nonstatic) arrays. */
arg_warned = warning_at (loc, OPT_Wnonnull,
- "%Kargument %i to %<%T[static %E]%> "
+ "argument %i to %<%T[static %E]%> "
"is null where non-null expected",
- exp, ptridx + 1, argtype,
+ ptridx + 1, argtype,
access_size);
}
@@ -11391,7 +11391,7 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
/* All valid uses of __builtin_va_arg_pack () are removed during
inlining. */
if (CALL_EXPR_VA_ARG_PACK (exp))
- error ("%Kinvalid use of %<__builtin_va_arg_pack ()%>", exp);
+ error ("invalid use of %<__builtin_va_arg_pack ()%>");
{
tree fndecl = get_callee_fndecl (exp), attr;
@@ -11403,7 +11403,7 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
DECL_ATTRIBUTES (fndecl))) != NULL)
{
const char *ident = lang_hooks.decl_printable_name (fndecl, 1);
- error ("%Kcall to %qs declared with attribute error: %s", exp,
+ error ("call to %qs declared with attribute error: %s",
identifier_to_locale (ident),
TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))));
}
@@ -11415,10 +11415,10 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
DECL_ATTRIBUTES (fndecl))) != NULL)
{
const char *ident = lang_hooks.decl_printable_name (fndecl, 1);
- warning_at (tree_nonartificial_location (exp),
+ warning_at (EXPR_LOCATION (exp),
OPT_Wattribute_warning,
- "%Kcall to %qs declared with attribute warning: %s",
- exp, identifier_to_locale (ident),
+ "call to %qs declared with attribute warning: %s",
+ identifier_to_locale (ident),
TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))));
}
@@ -2115,13 +2115,13 @@ gimple_fold_builtin_strncpy (gimple_stmt_iterator *gsi,
tree slen = get_maxval_strlen (src, SRK_STRLEN);
if (slen && !integer_zerop (slen))
warning_at (loc, OPT_Wstringop_truncation,
- "%G%qD destination unchanged after copying no bytes "
+ "%qD destination unchanged after copying no bytes "
"from a string of length %E",
- stmt, fndecl, slen);
+ fndecl, slen);
else
warning_at (loc, OPT_Wstringop_truncation,
- "%G%qD destination unchanged after copying no bytes",
- stmt, fndecl);
+ "%qD destination unchanged after copying no bytes",
+ fndecl);
}
replace_call_with_value (gsi, dest);
@@ -2498,11 +2498,11 @@ gimple_fold_builtin_strncat (gimple_stmt_iterator *gsi)
location_t loc = gimple_location (stmt);
nowarn = warning_at (loc, OPT_Wstringop_overflow_,
cmpdst == 0
- ? G_("%G%qD specified bound %E equals "
+ ? G_("%qD specified bound %E equals "
"destination size")
- : G_("%G%qD specified bound %E exceeds "
+ : G_("%qD specified bound %E exceeds "
"destination size %wu"),
- stmt, fndecl, len, dstsize);
+ fndecl, len, dstsize);
if (nowarn)
gimple_set_no_warning (stmt, true);
}
@@ -2518,8 +2518,8 @@ gimple_fold_builtin_strncat (gimple_stmt_iterator *gsi)
of the destination is unknown (it's not an uncommon mistake
to specify as the bound to strncpy the length of the source). */
if (warning_at (loc, OPT_Wstringop_overflow_,
- "%G%qD specified bound %E equals source length",
- stmt, fndecl, len))
+ "%qD specified bound %E equals source length",
+ fndecl, len))
gimple_set_no_warning (stmt, true);
}
@@ -3113,9 +3113,8 @@ format_directive (const call_info &info,
if (fmtres.nullp)
{
fmtwarn (dirloc, argloc, NULL, info.warnopt (),
- "%G%<%.*s%> directive argument is null",
- info.callstmt, dirlen,
- target_to_host (hostdir, sizeof hostdir, dir.beg));
+ "%<%.*s%> directive argument is null",
+ dirlen, target_to_host (hostdir, sizeof hostdir, dir.beg));
/* Don't bother processing the rest of the format string. */
res->warned = true;
@@ -4618,8 +4617,7 @@ handle_printf_call (gimple_stmt_iterator *gsi, pointer_query &ptr_qry)
is not constant. */
location_t loc = gimple_location (info.callstmt);
warning_at (EXPR_LOC_OR_LOC (dstptr, loc),
- info.warnopt (), "%Gnull destination pointer",
- info.callstmt);
+ info.warnopt (), "null destination pointer");
return false;
}
@@ -4648,8 +4646,7 @@ handle_printf_call (gimple_stmt_iterator *gsi, pointer_query &ptr_qry)
{
location_t loc = gimple_location (info.callstmt);
warning_at (EXPR_LOC_OR_LOC (info.format, loc),
- info.warnopt (), "%Gnull format string",
- info.callstmt);
+ info.warnopt (), "null format string");
return false;
}
@@ -283,7 +283,7 @@ pass_walloca::execute (function *fun)
}
else if (warn_alloca)
{
- warning_at (loc, OPT_Walloca, "%Guse of %<alloca%>", stmt);
+ warning_at (loc, OPT_Walloca, "use of %<alloca%>");
continue;
}
else if (warn_alloca_limit < 0)
@@ -322,11 +322,10 @@ pass_walloca::execute (function *fun)
auto_diagnostic_group d;
if (warning_at (loc, wcode,
(is_vla
- ? G_("%Gargument to variable-length "
+ ? G_("argument to variable-length "
"array may be too large")
- : G_("%Gargument to %<alloca%> may be too "
- "large")),
- stmt)
+ : G_("argument to %<alloca%> may be too "
+ "large")))
&& t.limit != 0)
{
print_decu (t.limit, buff);
@@ -342,10 +341,9 @@ pass_walloca::execute (function *fun)
auto_diagnostic_group d;
if (warning_at (loc, wcode,
(is_vla
- ? G_("%Gargument to variable-length"
+ ? G_("argument to variable-length"
" array is too large")
- : G_("%Gargument to %<alloca%> is too large")),
- stmt)
+ : G_("argument to %<alloca%> is too large")))
&& t.limit != 0)
{
print_decu (t.limit, buff);
@@ -361,22 +359,20 @@ pass_walloca::execute (function *fun)
warning_at (loc, wcode,
(is_vla
- ? G_("%Gunbounded use of variable-length array")
- : G_("%Gunbounded use of %<alloca%>")),
- stmt);
+ ? G_("unbounded use of variable-length array")
+ : G_("unbounded use of %<alloca%>")));
break;
case ALLOCA_IN_LOOP:
gcc_assert (!is_vla);
warning_at (loc, wcode,
- "%Guse of %<alloca%> within a loop", stmt);
+ "use of %<alloca%> within a loop");
break;
case ALLOCA_ARG_IS_ZERO:
warning_at (loc, wcode,
(is_vla
- ? G_("%Gargument to variable-length array "
+ ? G_("argument to variable-length array "
"is zero")
- : G_("%Gargument to %<alloca%> is zero")),
- stmt);
+ : G_("argument to %<alloca%> is zero")));
break;
default:
gcc_unreachable ();
@@ -1494,36 +1494,36 @@ maybe_diag_overlap (location_t loc, gimple *call, builtin_access &acs)
warning_at (loc, OPT_Wrestrict,
sizrange[0] == 1
? (ovlsiz[0] == 1
- ? G_("%G%qD accessing %wu byte at offsets %s "
+ ? G_("%qD accessing %wu byte at offsets %s "
"and %s overlaps %wu byte at offset %s")
- : G_("%G%qD accessing %wu byte at offsets %s "
+ : G_("%qD accessing %wu byte at offsets %s "
"and %s overlaps %wu bytes at offset "
"%s"))
: (ovlsiz[0] == 1
- ? G_("%G%qD accessing %wu bytes at offsets %s "
+ ? G_("%qD accessing %wu bytes at offsets %s "
"and %s overlaps %wu byte at offset %s")
- : G_("%G%qD accessing %wu bytes at offsets %s "
+ : G_("%qD accessing %wu bytes at offsets %s "
"and %s overlaps %wu bytes at offset "
"%s")),
- call, func, sizrange[0],
+ func, sizrange[0],
offstr[0], offstr[1], ovlsiz[0], offstr[2]);
else if (ovlsiz[1] >= 0 && ovlsiz[1] < maxobjsize.to_shwi ())
warning_n (loc, OPT_Wrestrict, sizrange[0],
- "%G%qD accessing %wu byte at offsets %s "
+ "%qD accessing %wu byte at offsets %s "
"and %s overlaps between %wu and %wu bytes "
"at offset %s",
- "%G%qD accessing %wu bytes at offsets %s "
+ "%qD accessing %wu bytes at offsets %s "
"and %s overlaps between %wu and %wu bytes "
"at offset %s",
- call, func, sizrange[0], offstr[0], offstr[1],
+ func, sizrange[0], offstr[0], offstr[1],
ovlsiz[0], ovlsiz[1], offstr[2]);
else
warning_n (loc, OPT_Wrestrict, sizrange[0],
- "%G%qD accessing %wu byte at offsets %s and "
+ "%qD accessing %wu byte at offsets %s and "
"%s overlaps %wu or more bytes at offset %s",
- "%G%qD accessing %wu bytes at offsets %s and "
+ "%qD accessing %wu bytes at offsets %s and "
"%s overlaps %wu or more bytes at offset %s",
- call, func, sizrange[0],
+ func, sizrange[0],
offstr[0], offstr[1], ovlsiz[0], offstr[2]);
return true;
}
@@ -1532,28 +1532,28 @@ maybe_diag_overlap (location_t loc, gimple *call, builtin_access &acs)
{
if (ovlsiz[0] == ovlsiz[1])
warning_n (loc, OPT_Wrestrict, ovlsiz[0],
- "%G%qD accessing between %wu and %wu bytes "
+ "%qD accessing between %wu and %wu bytes "
"at offsets %s and %s overlaps %wu byte at "
"offset %s",
- "%G%qD accessing between %wu and %wu bytes "
+ "%qD accessing between %wu and %wu bytes "
"at offsets %s and %s overlaps %wu bytes "
"at offset %s",
- call, func, sizrange[0], sizrange[1],
+ func, sizrange[0], sizrange[1],
offstr[0], offstr[1], ovlsiz[0], offstr[2]);
else if (ovlsiz[1] >= 0 && ovlsiz[1] < maxobjsize.to_shwi ())
warning_at (loc, OPT_Wrestrict,
- "%G%qD accessing between %wu and %wu bytes at "
+ "%qD accessing between %wu and %wu bytes at "
"offsets %s and %s overlaps between %wu and %wu "
"bytes at offset %s",
- call, func, sizrange[0], sizrange[1],
+ func, sizrange[0], sizrange[1],
offstr[0], offstr[1], ovlsiz[0], ovlsiz[1],
offstr[2]);
else
warning_at (loc, OPT_Wrestrict,
- "%G%qD accessing between %wu and %wu bytes at "
+ "%qD accessing between %wu and %wu bytes at "
"offsets %s and %s overlaps %wu or more bytes "
"at offset %s",
- call, func, sizrange[0], sizrange[1],
+ func, sizrange[0], sizrange[1],
offstr[0], offstr[1], ovlsiz[0], offstr[2]);
return true;
}
@@ -1563,24 +1563,24 @@ maybe_diag_overlap (location_t loc, gimple *call, builtin_access &acs)
if (ovlsiz[0] == ovlsiz[1])
warning_n (loc, OPT_Wrestrict, ovlsiz[0],
- "%G%qD accessing %wu or more bytes at offsets "
+ "%qD accessing %wu or more bytes at offsets "
"%s and %s overlaps %wu byte at offset %s",
- "%G%qD accessing %wu or more bytes at offsets "
+ "%qD accessing %wu or more bytes at offsets "
"%s and %s overlaps %wu bytes at offset %s",
- call, func, sizrange[0], offstr[0], offstr[1],
+ func, sizrange[0], offstr[0], offstr[1],
ovlsiz[0], offstr[2]);
else if (ovlsiz[1] >= 0 && ovlsiz[1] < maxobjsize.to_shwi ())
warning_at (loc, OPT_Wrestrict,
- "%G%qD accessing %wu or more bytes at offsets %s "
+ "%qD accessing %wu or more bytes at offsets %s "
"and %s overlaps between %wu and %wu bytes "
"at offset %s",
- call, func, sizrange[0], offstr[0], offstr[1],
+ func, sizrange[0], offstr[0], offstr[1],
ovlsiz[0], ovlsiz[1], offstr[2]);
else
warning_at (loc, OPT_Wrestrict,
- "%G%qD accessing %wu or more bytes at offsets %s "
+ "%qD accessing %wu or more bytes at offsets %s "
"and %s overlaps %wu or more bytes at offset %s",
- call, func, sizrange[0], offstr[0], offstr[1],
+ func, sizrange[0], offstr[0], offstr[1],
ovlsiz[0], offstr[2]);
return true;
}
@@ -1606,36 +1606,36 @@ maybe_diag_overlap (location_t loc, gimple *call, builtin_access &acs)
{
if (open_range)
warning_n (loc, OPT_Wrestrict, sizrange[1],
- "%G%qD accessing %wu byte may overlap "
+ "%qD accessing %wu byte may overlap "
"%wu byte",
- "%G%qD accessing %wu bytes may overlap "
+ "%qD accessing %wu bytes may overlap "
"%wu byte",
- call, func, sizrange[1], ovlsiz[1]);
+ func, sizrange[1], ovlsiz[1]);
else
warning_n (loc, OPT_Wrestrict, sizrange[1],
- "%G%qD accessing %wu byte at offsets %s "
+ "%qD accessing %wu byte at offsets %s "
"and %s may overlap %wu byte at offset %s",
- "%G%qD accessing %wu bytes at offsets %s "
+ "%qD accessing %wu bytes at offsets %s "
"and %s may overlap %wu byte at offset %s",
- call, func, sizrange[1], offstr[0], offstr[1],
+ func, sizrange[1], offstr[0], offstr[1],
ovlsiz[1], offstr[2]);
return true;
}
if (open_range)
warning_n (loc, OPT_Wrestrict, sizrange[1],
- "%G%qD accessing %wu byte may overlap "
+ "%qD accessing %wu byte may overlap "
"up to %wu bytes",
- "%G%qD accessing %wu bytes may overlap "
+ "%qD accessing %wu bytes may overlap "
"up to %wu bytes",
- call, func, sizrange[1], ovlsiz[1]);
+ func, sizrange[1], ovlsiz[1]);
else
warning_n (loc, OPT_Wrestrict, sizrange[1],
- "%G%qD accessing %wu byte at offsets %s and "
+ "%qD accessing %wu byte at offsets %s and "
"%s may overlap up to %wu bytes at offset %s",
- "%G%qD accessing %wu bytes at offsets %s and "
+ "%qD accessing %wu bytes at offsets %s and "
"%s may overlap up to %wu bytes at offset %s",
- call, func, sizrange[1], offstr[0], offstr[1],
+ func, sizrange[1], offstr[0], offstr[1],
ovlsiz[1], offstr[2]);
return true;
}
@@ -1644,30 +1644,30 @@ maybe_diag_overlap (location_t loc, gimple *call, builtin_access &acs)
{
if (open_range)
warning_n (loc, OPT_Wrestrict, ovlsiz[1],
- "%G%qD accessing between %wu and %wu bytes "
+ "%qD accessing between %wu and %wu bytes "
"may overlap %wu byte",
- "%G%qD accessing between %wu and %wu bytes "
+ "%qD accessing between %wu and %wu bytes "
"may overlap up to %wu bytes",
- call, func, sizrange[0], sizrange[1], ovlsiz[1]);
+ func, sizrange[0], sizrange[1], ovlsiz[1]);
else
warning_n (loc, OPT_Wrestrict, ovlsiz[1],
- "%G%qD accessing between %wu and %wu bytes "
+ "%qD accessing between %wu and %wu bytes "
"at offsets %s and %s may overlap %wu byte "
"at offset %s",
- "%G%qD accessing between %wu and %wu bytes "
+ "%qD accessing between %wu and %wu bytes "
"at offsets %s and %s may overlap up to %wu "
"bytes at offset %s",
- call, func, sizrange[0], sizrange[1],
+ func, sizrange[0], sizrange[1],
offstr[0], offstr[1], ovlsiz[1], offstr[2]);
return true;
}
warning_n (loc, OPT_Wrestrict, ovlsiz[1],
- "%G%qD accessing %wu or more bytes at offsets %s "
+ "%qD accessing %wu or more bytes at offsets %s "
"and %s may overlap %wu byte at offset %s",
- "%G%qD accessing %wu or more bytes at offsets %s "
+ "%qD accessing %wu or more bytes at offsets %s "
"and %s may overlap up to %wu bytes at offset %s",
- call, func, sizrange[0], offstr[0], offstr[1],
+ func, sizrange[0], offstr[0], offstr[1],
ovlsiz[1], offstr[2]);
return true;
@@ -1688,7 +1688,7 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict,
const builtin_memref &ref, offset_int wroff,
bool do_warn)
{
- location_t loc = gimple_or_expr_nonartificial_location (call, ref.ptr);
+ location_t loc = gimple_location (call);
const offset_int maxobjsize = ref.maxobjsize;
/* Check for excessive size first and regardless of warning options
@@ -1706,15 +1706,15 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict,
{
if (ref.sizrange[0] == ref.sizrange[1])
return warning_at (loc, OPT_Wstringop_overflow_,
- "%G%qD specified bound %wu "
+ "%qD specified bound %wu "
"exceeds maximum object size %wu",
- call, func, ref.sizrange[0].to_uhwi (),
+ func, ref.sizrange[0].to_uhwi (),
maxobjsize.to_uhwi ());
return warning_at (loc, OPT_Wstringop_overflow_,
- "%G%qD specified bound between %wu and %wu "
+ "%qD specified bound between %wu and %wu "
"exceeds maximum object size %wu",
- call, func, ref.sizrange[0].to_uhwi (),
+ func, ref.sizrange[0].to_uhwi (),
ref.sizrange[1].to_uhwi (),
maxobjsize.to_uhwi ());
}
@@ -1771,9 +1771,9 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict,
{
auto_diagnostic_group d;
if (warning_at (loc, OPT_Warray_bounds,
- "%G%qD pointer overflow between offset %s "
+ "%qD pointer overflow between offset %s "
"and size %s accessing array %qD with type %qT",
- call, func, rangestr[0], rangestr[1], ref.base, type))
+ func, rangestr[0], rangestr[1], ref.base, type))
{
inform (DECL_SOURCE_LOCATION (ref.base),
"array %qD declared here", ref.base);
@@ -1781,15 +1781,15 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict,
}
else
warned = warning_at (loc, OPT_Warray_bounds,
- "%G%qD pointer overflow between offset %s "
+ "%qD pointer overflow between offset %s "
"and size %s",
- call, func, rangestr[0], rangestr[1]);
+ func, rangestr[0], rangestr[1]);
}
else
warned = warning_at (loc, OPT_Warray_bounds,
- "%G%qD pointer overflow between offset %s "
+ "%qD pointer overflow between offset %s "
"and size %s",
- call, func, rangestr[0], rangestr[1]);
+ func, rangestr[0], rangestr[1]);
}
else if (oobref == ref.base)
{
@@ -1804,20 +1804,20 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict,
if ((ref.basesize < maxobjsize
&& warning_at (loc, OPT_Warray_bounds,
form
- ? G_("%G%qD forming offset %s is out of "
+ ? G_("%qD forming offset %s is out of "
"the bounds [0, %wu] of object %qD with "
"type %qT")
- : G_("%G%qD offset %s is out of the bounds "
+ : G_("%qD offset %s is out of the bounds "
"[0, %wu] of object %qD with type %qT"),
- call, func, rangestr[0], ref.basesize.to_uhwi (),
+ func, rangestr[0], ref.basesize.to_uhwi (),
ref.base, TREE_TYPE (ref.base)))
|| warning_at (loc, OPT_Warray_bounds,
form
- ? G_("%G%qD forming offset %s is out of "
+ ? G_("%qD forming offset %s is out of "
"the bounds of object %qD with type %qT")
- : G_("%G%qD offset %s is out of the bounds "
+ : G_("%qD offset %s is out of the bounds "
"of object %qD with type %qT"),
- call, func, rangestr[0],
+ func, rangestr[0],
ref.base, TREE_TYPE (ref.base)))
{
inform (DECL_SOURCE_LOCATION (ref.base),
@@ -1828,17 +1828,17 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict,
else if (ref.basesize < maxobjsize)
warned = warning_at (loc, OPT_Warray_bounds,
form
- ? G_("%G%qD forming offset %s is out "
+ ? G_("%qD forming offset %s is out "
"of the bounds [0, %wu]")
- : G_("%G%qD offset %s is out "
+ : G_("%qD offset %s is out "
"of the bounds [0, %wu]"),
- call, func, rangestr[0], ref.basesize.to_uhwi ());
+ func, rangestr[0], ref.basesize.to_uhwi ());
else
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"),
- call, func, rangestr[0]);
+ ? G_("%qD forming offset %s is out of bounds")
+ : G_("%qD offset %s is out of bounds"),
+ func, rangestr[0]);
}
else if (TREE_CODE (ref.ref) == MEM_REF)
{
@@ -1849,9 +1849,9 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict,
type = TYPE_MAIN_VARIANT (type);
if (warning_at (loc, OPT_Warray_bounds,
- "%G%qD offset %s from the object at %qE is out "
+ "%qD offset %s from the object at %qE is out "
"of the bounds of %qT",
- call, func, rangestr[0], ref.base, type))
+ func, rangestr[0], ref.base, type))
{
if (TREE_CODE (ref.ref) == COMPONENT_REF)
refop = TREE_OPERAND (ref.ref, 1);
@@ -1867,10 +1867,10 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict,
tree type = TYPE_MAIN_VARIANT (TREE_TYPE (ref.ref));
if (warning_at (loc, OPT_Warray_bounds,
- "%G%qD offset %s from the object at %qE is out "
+ "%qD offset %s from the object at %qE is out "
"of the bounds of referenced subobject %qD with "
"type %qT at offset %wi",
- call, func, rangestr[0], ref.base,
+ func, rangestr[0], ref.base,
TREE_OPERAND (ref.ref, 1), type,
ref.refoff.to_shwi ()))
{
@@ -2057,7 +2057,7 @@ check_bounds_or_overlap (range_query *query,
}
}
- location_t loc = gimple_or_expr_nonartificial_location (call, dst);
+ location_t loc = gimple_location (call);
if (operand_equal_p (dst, src, 0))
{
/* Issue -Wrestrict unless the pointers are null (those do
@@ -2067,8 +2067,8 @@ check_bounds_or_overlap (range_query *query,
if (!integer_zerop (dst) && !gimple_no_warning_p (call))
{
warning_at (loc, OPT_Wrestrict,
- "%G%qD source argument is the same as destination",
- call, func);
+ "%qD source argument is the same as destination",
+ func);
gimple_set_no_warning (call, true);
return OPT_Wrestrict;
}
new file mode 100644
new file mode 100644
@@ -0,0 +1,7 @@
+/* Verify that -Warray-bounds suppression via #pragma GCC diagnostic
+ works at any call site in an inlining stack
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+#define IGNORE '1'
+#include "Warray-bounds-71.h"
new file mode 100644
@@ -0,0 +1,46 @@
+/* Verify that -Warray-bounds suppression via #pragma GCC diagnostic
+ works at any call site in an inlining stack
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+int a[4];
+
+void f1 (int *p, int i)
+{
+#pragma GCC diagnostic push
+#if IGNORE == '1'
+# pragma GCC diagnostic ignored "-Warray-bounds"
+#endif
+ p[i + 1] = 0;
+#pragma GCC diagnostic pop
+}
+
+void f2 (int *p, int i)
+{
+#pragma GCC diagnostic push
+#if IGNORE == '2'
+# pragma GCC diagnostic ignored "-Warray-bounds"
+#endif
+ f1 (p + 1, i + 1);
+#pragma GCC diagnostic pop
+}
+
+void f3 (int *p, int i)
+{
+#pragma GCC diagnostic push
+#if IGNORE == '3'
+# pragma GCC diagnostic ignored "-Warray-bounds"
+#endif
+ f2 (p + 1, i + 1);
+#pragma GCC diagnostic pop
+}
+
+void f4 (void)
+{
+#pragma GCC diagnostic push
+#if IGNORE == '4'
+# pragma GCC diagnostic ignored "-Warray-bounds"
+#endif
+ f3 (a, 1);
+#pragma GCC diagnostic pop
+}
new file mode 100644
@@ -0,0 +1,7 @@
+/* Verify that -Warray-bounds suppression via #pragma GCC diagnostic
+ works at any call site in an inlining stack
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+#define IGNORE '2'
+#include "Warray-bounds-71.h"
new file mode 100644
@@ -0,0 +1,7 @@
+/* Verify that -Warray-bounds suppression via #pragma GCC diagnostic
+ works at any call site in an inlining stack
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+#define IGNORE '3'
+#include "Warray-bounds-71.h"
new file mode 100644
@@ -0,0 +1,7 @@
+/* Verify that -Warray-bounds suppression via #pragma GCC diagnostic
+ works at any call site in an inlining stack
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+#define IGNORE '4'
+#include "Warray-bounds-71.h"
new file mode 100644
@@ -0,0 +1,12 @@
+/* Sanity test for Warray-bounds-7[1-4].c. Also verify the expected
+ inlining stack.
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+#include "Warray-bounds-71.h"
+
+// { dg-regexp "In function 'f1'," "In function f1" { target *-*-* } 0 }
+// { dg-regexp "inlined from 'f2' at \[^\\n\\r\]+\[\\n\\r\]" "inlined from f2" { target *-*-* } 0 }
+// { dg-regexp "inlined from 'f3' at \[^\\n\\r\]+\[\\n\\r\]" "inlined from f3" { target *-*-* } 0 }
+// { dg-regexp "inlined from 'f4' at \[^\\n\\r\]+\[\\n\\r\]" "inlined from f4" { target *-*-* } 0 }
+// { dg-message "Warray-bounds-71.h:\\d+:\\d+: warning: array subscript 6 is outside array bounds of 'int\\\[4]'" "warning" { target *-*-* } 0 }
@@ -26,7 +26,7 @@ void g2 (struct A *p) { g1 (p); }
#define NOIPA __attribute__ ((noipa))
-extern int array[];
+extern int array[]; // { dg-message "declared here" "note on line 29" }
/* Verify the warning is issued even for calls in a system header inlined
into a function outside the header. */
@@ -39,7 +39,7 @@ NOIPA void warn_g0 (struct A *p)
g0 (p);
}
-// { dg-message "inlined from 'warn_g0'" "" { target *-*-* } 0 }
+// { dg-message "inlined from 'warn_g0'" "note on line 42" { target *-*-* } 0 }
/* Also verify the warning can be suppressed. */
@@ -65,8 +65,8 @@ NOIPA void warn_g1 (struct A *p)
g1 (p);
}
-// { dg-message "inlined from 'g1'" "" { target *-*-* } 0 }
-// { dg-message "inlined from 'warn_g1'" "" { target *-*-* } 0 }
+// { dg-message "inlined from 'g1'" "note on line 68" { target *-*-* } 0 }
+// { dg-message "inlined from 'warn_g1'" "note on line 69" { target *-*-* } 0 }
NOIPA void nowarn_g1 (struct A *p)
@@ -90,8 +90,8 @@ NOIPA void warn_g2 (struct A *p)
g2 (p);
}
-// { dg-message "inlined from 'g2'" "" { target *-*-* } 0 }
-// { dg-message "inlined from 'warn_g2'" "" { target *-*-* } 0 }
+// { dg-message "inlined from 'g2'" "note on line 93" { target *-*-* } 0 }
+// { dg-message "inlined from 'warn_g2'" "note on line 94" { target *-*-* } 0 }
NOIPA void nowarn_g2 (struct A *p)
new file mode 100644
@@ -0,0 +1,45 @@
+/* Similar to Wfree-nonheap-object-4.c but without system headers:
+ verify that warnings for the same call site from distinct callers
+ include the correct function names in the inlining stack.
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+struct A
+{
+ void *p;
+};
+
+void f0 (struct A *p)
+{
+ __builtin_free (p->p); // { dg-warning "\\\[-Wfree-nonheap-object" }
+}
+
+// Expect two instances of the text below:
+// { dg-regexp "In function 'f0'," "f0 prefix" { target *-*-* } 0 }
+// { dg-regexp "In function 'f0'," "f0 prefix" { target *-*-* } 0 }
+
+void f1 (struct A *p) { f0 (p); }
+void f2 (struct A *p) { f1 (p); }
+
+extern int array[];
+// Also expect two instances of the note:
+// { dg-regexp "declared here" "note on line 24" { target *-*-* } .-2 }
+// { dg-regexp "declared here" "note on line 24" { target *-*-* } .-3 }
+
+void foo (struct A *p)
+{
+ p->p = array + 1;
+ f0 (p);
+}
+
+// { dg-message "inlined from 'foo'" "note on line 35" { target *-*-* } 0 }
+
+
+void bar (struct A *p)
+{
+ p->p = array + 2;
+ f1 (p);
+}
+
+// { dg-message "inlined from 'f1'" "note on line 44" { target *-*-* } 0 }
+// { dg-message "inlined from 'bar'" "note on line 45" { target *-*-* } 0 }
@@ -4,13 +4,17 @@
#include "Wobjsize-1.h"
char buf[6];
-/* { dg-warning "writing" "" { target *-*-* } .-1 } */
int main(int argc, char **argv)
{
- strcpy (buf,"hello ");
+ strcpy (buf,"hello "); /* { dg-warning "\\\[-Wstringop-overflow" } */
return 0;
}
-/* { dg-message "file included" "included" { target *-*-* } 0 } */
-/* { dg-message "inlined from" "inlined" { target *-*-* } 0 } */
+/* { dg-message "file included" "included" { target *-*-* } 0 }
+ { dg-message "inlined from" "inlined" { target *-*-* } 0 }
+
+ The test might emit two warnings, one for the strcpy call and
+ another for the inlined call to __builtin___strcpy_chk() called
+ from strcpy().
+ { dg-prune-output "writing 7 bytes into a region of size 6" } */
new file mode 100644
@@ -0,0 +1,20 @@
+/* PR middle-end/98512 - #pragma GCC diagnostic ignored ineffective
+ in conjunction with alias attribute
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+void *
+__rawmemchr_ppc (const void *s, int c)
+{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#pragma GCC diagnostic ignored "-Wstringop-overread"
+ if (c != 0)
+ return __builtin_memchr (s, c, (unsigned long)-1); // { dg-bogus "specified bound \\d+ exceeds maximum object size" }
+#pragma GCC diagnostic pop
+
+ return (char *)s + __builtin_strlen (s);
+}
+
+extern __typeof (__rawmemchr_ppc) __EI___rawmemchr_ppc
+ __attribute__((alias ("__rawmemchr_ppc")));
new file mode 100644
@@ -0,0 +1,134 @@
+/* Verify that #pragma GCC diagnostic down the inlining stack suppresses
+ a warning that would otherwise be issued for inlined calls higher up
+ the inlining stack.
+ { dg-do compile }
+ { dg-options "-O2 -Wall -Wno-array-bounds" } */
+
+extern void* memset (void*, int, __SIZE_TYPE__);
+
+static void warn0 (int *p)
+{
+ memset (p, __LINE__, 3); // { dg-warning "\\\[-Wstringop-overflow" }
+}
+
+static void warn1 (int *p)
+{
+ warn0 (p + 1);
+}
+
+static void warn2 (int *p)
+{
+ warn1 (p + 1);
+}
+
+int a2[2]; // { dg-message "at offset 12 into destination object 'a2' of size 8" }
+
+void warn3 (void)
+{
+ warn2 (a2 + 1);
+}
+
+
+static void ignore0 (int *p)
+{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+ memset (p, __LINE__, 3);
+#pragma GCC diagnostic pop
+}
+
+static void nowarn1_ignore0 (int *p)
+{
+ ignore0 (p + 1);
+}
+
+static void nowarn2_ignore0 (int *p)
+{
+ nowarn1_ignore0 (p + 1);
+}
+
+int b2[2];
+
+void nowarn3_ignore0 (void)
+{
+ nowarn2_ignore0 (b2 + 1);
+}
+
+
+static void nowarn0_ignore1 (int *p)
+{
+ memset (p, __LINE__, 3);
+}
+
+static void ignore1 (int *p)
+{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+ nowarn0_ignore1 (p + 1);
+#pragma GCC diagnostic pop
+}
+
+void nowarn2_ignore1 (int *p)
+{
+ ignore1 (p + 1);
+}
+
+int c2[2];
+
+void nowarn3_ignore1 (void)
+{
+ nowarn2_ignore1 (c2 + 1);
+}
+
+
+static void nowarn0_ignore2 (int *p)
+{
+ memset (p, __LINE__, 3);
+}
+
+static void nowarn1_ignore2 (int *p)
+{
+ nowarn0_ignore2 (p + 1);
+}
+
+static void ignore2 (int *p)
+{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+ nowarn1_ignore2 (p + 1);
+#pragma GCC diagnostic pop
+}
+
+int d2[2];
+
+void nowarn3_ignore2 (void)
+{
+ ignore2 (c2 + 1);
+}
+
+
+
+static void nowarn0_ignore3 (int *p)
+{
+ memset (p, __LINE__, 3);
+}
+
+static void nowarn1_ignore3 (int *p)
+{
+ nowarn0_ignore3 (p + 1);
+}
+
+static void nowarn2_ignore3 (int *p)
+{
+ nowarn1_ignore3 (p + 1);
+}
+
+int e2[2];
+
+void ignore3 (void)
+{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+ nowarn2_ignore3 (e2 + 1);
+#pragma GCC diagnostic pop
+}
new file mode 100644
@@ -0,0 +1,98 @@
+/* PR middle-end/98871 - Cannot silence -Wmaybe-uninitialized at declaration
+ site
+ { dg-do compile }
+ { dg-options "-O1 -Wall" } */
+
+struct A
+{
+ int x;
+};
+
+// Verify that suppression works at every inlining level.
+
+static int f0 (int *x)
+{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+
+ return ++*x;
+
+#pragma GCC diagnostic pop
+}
+
+static int f1 (int *p, int n)
+{
+ struct A a;
+ for (int i = 0; i < n; ++i) {
+ if (p[i] > 1) {
+ a = (struct A){p[i]};
+ }
+ }
+
+ return f0 (&a.x);
+}
+
+int f2 (void)
+{
+ int a[] = { 1, 2, 3, 4 };
+ return f1 (a, 4);
+}
+
+
+static int g0 (int *x)
+{
+ return ++*x;
+}
+
+static int g1 (int *p, int n)
+{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+
+ struct A a;
+ for (int i = 0; i < n; ++i) {
+ if (p[i] > 1) {
+ a = (struct A){p[i]};
+ }
+ }
+
+ return g0 (&a.x);
+
+#pragma GCC diagnostic pop
+}
+
+int g2 (void)
+{
+ int a[] = { 1, 2, 3, 4, 5 };
+ return g1 (a, 5);
+}
+
+
+static int h0 (int *x)
+{
+ return ++*x;
+}
+
+static int h1 (int *p, int n)
+{
+ struct A a;
+ for (int i = 0; i < n; ++i) {
+ if (p[i] > 1) {
+ a = (struct A){p[i]};
+ }
+ }
+
+ return h0 (&a.x);
+}
+
+int h2 (void)
+{
+ int a[] = { 1, 2, 3, 4, 5, 6 };
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+
+ return h1 (a, 6);
+
+#pragma GCC diagnostic pop
+}
@@ -4413,12 +4413,8 @@ ipa_tm_scan_irr_block (basic_block bb)
is to wrap it in a __tm_waiver block. This is not
yet implemented, so we can't check for it. */
if (is_tm_safe (current_function_decl))
- {
- tree t = build1 (NOP_EXPR, void_type_node, size_zero_node);
- SET_EXPR_LOCATION (t, gimple_location (stmt));
- error ("%K%<asm%> not allowed in %<transaction_safe%> function",
- t);
- }
+ error_at (gimple_location (stmt),
+ "%<asm%> not allowed in %<transaction_safe%> function");
return true;
default:
@@ -3563,7 +3563,7 @@ pass_post_ipa_warn::execute (function *fun)
if (argno == 0)
{
if (warning_at (loc, OPT_Wnonnull,
- "%G%qs pointer is null", stmt, "this")
+ "%qs pointer is null", "this")
&& fndecl)
inform (DECL_SOURCE_LOCATION (fndecl),
"in a call to non-static member function %qD",
@@ -3572,8 +3572,8 @@ pass_post_ipa_warn::execute (function *fun)
}
if (!warning_at (loc, OPT_Wnonnull,
- "%Gargument %u null where non-null "
- "expected", stmt, argno))
+ "argument %u null where non-null "
+ "expected", argno))
continue;
tree fndecl = gimple_call_fndecl (stmt);
@@ -2019,13 +2019,12 @@ maybe_warn_overflow (gimple *stmt, tree len, pointer_query &ptr_qry,
warned = (writefn
? warning_at (loc, OPT_Wstringop_overflow_,
- "%G%qD writing one too many bytes into a region "
+ "%qD writing one too many bytes into a region "
"of a size that depends on %<strlen%>",
- stmt, writefn)
+ writefn)
: warning_at (loc, OPT_Wstringop_overflow_,
- "%Gwriting one too many bytes into a region "
- "of a size that depends on %<strlen%>",
- stmt));
+ "writing one too many bytes into a region "
+ "of a size that depends on %<strlen%>"));
}
else if (lenrng[0] == lenrng[1])
{
@@ -2033,65 +2032,65 @@ maybe_warn_overflow (gimple *stmt, tree len, pointer_query &ptr_qry,
warned = (writefn
? warning_n (loc, OPT_Wstringop_overflow_,
lenrng[0].to_uhwi (),
- "%G%qD writing %wu byte into a region "
+ "%qD writing %wu byte into a region "
"of size %wu",
- "%G%qD writing %wu bytes into a region "
+ "%qD writing %wu bytes into a region "
"of size %wu",
- stmt, writefn, lenrng[0].to_uhwi (),
+ writefn, lenrng[0].to_uhwi (),
spcrng[0].to_uhwi ())
: warning_n (loc, OPT_Wstringop_overflow_,
lenrng[0].to_uhwi (),
- "%Gwriting %wu byte into a region "
+ "writing %wu byte into a region "
"of size %wu",
- "%Gwriting %wu bytes into a region "
+ "writing %wu bytes into a region "
"of size %wu",
- stmt, lenrng[0].to_uhwi (),
+ lenrng[0].to_uhwi (),
spcrng[0].to_uhwi ()));
else
warned = (writefn
? warning_n (loc, OPT_Wstringop_overflow_,
lenrng[0].to_uhwi (),
- "%G%qD writing %wu byte into a region "
+ "%qD writing %wu byte into a region "
"of size between %wu and %wu",
- "%G%qD writing %wu bytes into a region "
+ "%qD writing %wu bytes into a region "
"of size between %wu and %wu",
- stmt, writefn, lenrng[0].to_uhwi (),
+ writefn, lenrng[0].to_uhwi (),
spcrng[0].to_uhwi (), spcrng[1].to_uhwi ())
: warning_n (loc, OPT_Wstringop_overflow_,
lenrng[0].to_uhwi (),
- "%Gwriting %wu byte into a region "
+ "writing %wu byte into a region "
"of size between %wu and %wu",
- "%Gwriting %wu bytes into a region "
+ "writing %wu bytes into a region "
"of size between %wu and %wu",
- stmt, lenrng[0].to_uhwi (),
+ lenrng[0].to_uhwi (),
spcrng[0].to_uhwi (), spcrng[1].to_uhwi ()));
}
else if (spcrng[0] == spcrng[1])
warned = (writefn
? warning_at (loc, OPT_Wstringop_overflow_,
- "%G%qD writing between %wu and %wu bytes "
+ "%qD writing between %wu and %wu bytes "
"into a region of size %wu",
- stmt, writefn, lenrng[0].to_uhwi (),
+ writefn, lenrng[0].to_uhwi (),
lenrng[1].to_uhwi (),
spcrng[0].to_uhwi ())
: warning_at (loc, OPT_Wstringop_overflow_,
- "%Gwriting between %wu and %wu bytes "
+ "writing between %wu and %wu bytes "
"into a region of size %wu",
- stmt, lenrng[0].to_uhwi (),
+ lenrng[0].to_uhwi (),
lenrng[1].to_uhwi (),
spcrng[0].to_uhwi ()));
else
warned = (writefn
? warning_at (loc, OPT_Wstringop_overflow_,
- "%G%qD writing between %wu and %wu bytes "
+ "%qD writing between %wu and %wu bytes "
"into a region of size between %wu and %wu",
- stmt, writefn, lenrng[0].to_uhwi (),
+ writefn, lenrng[0].to_uhwi (),
lenrng[1].to_uhwi (),
spcrng[0].to_uhwi (), spcrng[1].to_uhwi ())
: warning_at (loc, OPT_Wstringop_overflow_,
- "%Gwriting between %wu and %wu bytes "
+ "writing between %wu and %wu bytes "
"into a region of size between %wu and %wu",
- stmt, lenrng[0].to_uhwi (),
+ lenrng[0].to_uhwi (),
lenrng[1].to_uhwi (),
spcrng[0].to_uhwi (), spcrng[1].to_uhwi ()));
@@ -2982,13 +2981,13 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt,
if (lenrange[0] == cntrange[1] && cntrange[0] == cntrange[1])
return warning_n (callloc, OPT_Wstringop_truncation,
cntrange[0].to_uhwi (),
- "%G%qD output truncated before terminating "
+ "%qD output truncated before terminating "
"nul copying %E byte from a string of the "
"same length",
- "%G%qD output truncated before terminating nul "
+ "%qD output truncated before terminating nul "
"copying %E bytes from a string of the same "
"length",
- stmt, func, cnt);
+ func, cnt);
else if (!cat_dstlen_bounded)
{
if (wi::geu_p (lenrange[0], cntrange[1]))
@@ -2998,16 +2997,16 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt,
if (cntrange[0] == cntrange[1])
return warning_n (callloc, OPT_Wstringop_truncation,
cntrange[0].to_uhwi (),
- "%G%qD output truncated copying %E byte "
+ "%qD output truncated copying %E byte "
"from a string of length %wu",
- "%G%qD output truncated copying %E bytes "
+ "%qD output truncated copying %E bytes "
"from a string of length %wu",
- stmt, func, cnt, lenrange[0].to_uhwi ());
+ func, cnt, lenrange[0].to_uhwi ());
return warning_at (callloc, OPT_Wstringop_truncation,
- "%G%qD output truncated copying between %wu "
+ "%qD output truncated copying between %wu "
"and %wu bytes from a string of length %wu",
- stmt, func, cntrange[0].to_uhwi (),
+ func, cntrange[0].to_uhwi (),
cntrange[1].to_uhwi (), lenrange[0].to_uhwi ());
}
else if (wi::geu_p (lenrange[1], cntrange[1]))
@@ -3017,16 +3016,16 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt,
if (cntrange[0] == cntrange[1])
return warning_n (callloc, OPT_Wstringop_truncation,
cntrange[0].to_uhwi (),
- "%G%qD output may be truncated copying %E "
+ "%qD output may be truncated copying %E "
"byte from a string of length %wu",
- "%G%qD output may be truncated copying %E "
+ "%qD output may be truncated copying %E "
"bytes from a string of length %wu",
- stmt, func, cnt, lenrange[1].to_uhwi ());
+ func, cnt, lenrange[1].to_uhwi ());
return warning_at (callloc, OPT_Wstringop_truncation,
- "%G%qD output may be truncated copying between "
+ "%qD output may be truncated copying between "
"%wu and %wu bytes from a string of length %wu",
- stmt, func, cntrange[0].to_uhwi (),
+ func, cntrange[0].to_uhwi (),
cntrange[1].to_uhwi (), lenrange[1].to_uhwi ());
}
}
@@ -3040,9 +3039,9 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt,
the lower bound of the specified count but shorter than the
upper bound the copy may (but need not) be truncated. */
return warning_at (callloc, OPT_Wstringop_truncation,
- "%G%qD output may be truncated copying between "
+ "%qD output may be truncated copying between "
"%wu and %wu bytes from a string of length %wu",
- stmt, func, cntrange[0].to_uhwi (),
+ func, cntrange[0].to_uhwi (),
cntrange[1].to_uhwi (), lenrange[0].to_uhwi ());
}
}
@@ -3069,8 +3068,8 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt,
if (cntrange[0] == cntrange[1])
return warning_at (callloc, OPT_Wstringop_truncation,
- "%G%qD specified bound %E equals destination size",
- stmt, func, cnt);
+ "%qD specified bound %E equals destination size",
+ func, cnt);
}
return false;
@@ -3193,9 +3192,9 @@ handle_builtin_stxncpy_strncat (bool append_p, gimple_stmt_iterator *gsi)
&& sisrc == silen
&& is_strlen_related_p (src, len)
&& warning_at (callloc, OPT_Wstringop_truncation,
- "%G%qD output truncated before terminating nul "
+ "%qD output truncated before terminating nul "
"copying as many bytes from a string as its length",
- stmt, func))
+ func))
warned = true;
else if ((append_p || !dstsize || len == dstlenp1)
&& silen && is_strlen_related_p (src, silen->ptr))
@@ -3206,9 +3205,9 @@ handle_builtin_stxncpy_strncat (bool append_p, gimple_stmt_iterator *gsi)
int opt = (append_p || dstsize
? OPT_Wstringop_overflow_ : OPT_Wstringop_truncation);
warned = warning_at (callloc, opt,
- "%G%qD specified bound depends on the length "
+ "%qD specified bound depends on the length "
"of the source argument",
- stmt, func);
+ func);
}
if (warned)
{
@@ -4140,24 +4139,24 @@ maybe_warn_pointless_strcmp (gimple *stmt, HOST_WIDE_INT bound,
if (siz <= minlen && bound == -1)
warned = warning_at (stmt_loc, OPT_Wstring_compare,
(at_least
- ? G_("%G%qD of a string of length %wu or more and "
+ ? G_("%qD of a string of length %wu or more and "
"an array of size %wu evaluates to nonzero")
- : G_("%G%qD of a string of length %wu and an array "
+ : G_("%qD of a string of length %wu and an array "
"of size %wu evaluates to nonzero")),
- stmt, callee, minlen, siz);
+ callee, minlen, siz);
else if (!at_least && siz <= HOST_WIDE_INT_MAX)
{
if (len[0] != HOST_WIDE_INT_MAX && len[1] != HOST_WIDE_INT_MAX)
warned = warning_at (stmt_loc, OPT_Wstring_compare,
- "%G%qD of strings of length %wu and %wu "
+ "%qD of strings of length %wu and %wu "
"and bound of %wu evaluates to nonzero",
- stmt, callee, len[0], len[1], bound);
+ callee, len[0], len[1], bound);
else
warned = warning_at (stmt_loc, OPT_Wstring_compare,
- "%G%qD of a string of length %wu, an array "
+ "%qD of a string of length %wu, an array "
"of size %wu and bound of %wu evaluates to "
"nonzero",
- stmt, callee, minlen, siz, bound);
+ callee, minlen, siz, bound);
}
if (!warned)
@@ -428,7 +428,7 @@ maybe_warn_operand (ao_ref &ref, gimple *stmt, tree lhs, tree rhs,
if (wlims.always_executed)
{
if (warning_at (location, OPT_Wuninitialized,
- "%G%qE is used uninitialized", stmt, rhs))
+ "%qE is used uninitialized", rhs))
{
/* ??? This is only effective for decls as in
gcc.dg/uninit-B-O0.c. Avoid doing this for maybe-uninit
@@ -441,7 +441,7 @@ maybe_warn_operand (ao_ref &ref, gimple *stmt, tree lhs, tree rhs,
}
else if (wlims.wmaybe_uninit)
warned = warning_at (location, OPT_Wmaybe_uninitialized,
- "%G%qE may be used uninitialized", stmt, rhs);
+ "%qE may be used uninitialized", rhs);
return warned ? base : NULL_TREE;
}