diff options
author | Martin Sebor <msebor@redhat.com> | 2021-07-06 13:41:02 -0600 |
---|---|---|
committer | Martin Sebor <msebor@redhat.com> | 2021-07-06 13:43:11 -0600 |
commit | 6d3bab5d5adb3e28ddb16c97b0831efdea23cf7d (patch) | |
tree | e01626f7d19dbd576102341cc414accad07f4fbb /gcc/gimple-ssa-warn-restrict.c | |
parent | 03b634c8e0d3e8628ced79fc4f40873e12a3039c (diff) | |
download | gcc-6d3bab5d5adb3e28ddb16c97b0831efdea23cf7d.zip gcc-6d3bab5d5adb3e28ddb16c97b0831efdea23cf7d.tar.gz gcc-6d3bab5d5adb3e28ddb16c97b0831efdea23cf7d.tar.bz2 |
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/Wobjsize-1.c: Prune expected output.
* gcc.dg/Warray-bounds-71.c: New test.
* gcc.dg/Warray-bounds-71.h: New test header.
* 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-4.c: Adjust expected output.
* gcc.dg/Wfree-nonheap-object-5.c: New test.
* gcc.dg/Wfree-nonheap-object-6.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.
* gcc.dg/pr79214.c: Xfail tests.
* gcc.dg/tree-ssa/builtin-sprintf-warn-27.c: New test.
* gcc.dg/format/c90-printf-1.c: Adjust expected output.
Diffstat (limited to 'gcc/gimple-ssa-warn-restrict.c')
-rw-r--r-- | gcc/gimple-ssa-warn-restrict.c | 152 |
1 files changed, 76 insertions, 76 deletions
diff --git a/gcc/gimple-ssa-warn-restrict.c b/gcc/gimple-ssa-warn-restrict.c index 02771e4..efb8db9 100644 --- a/gcc/gimple-ssa-warn-restrict.c +++ b/gcc/gimple-ssa-warn-restrict.c @@ -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; @@ -1689,7 +1689,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 @@ -1709,15 +1709,15 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict, { if (ref.sizrange[0] == ref.sizrange[1]) warned = warning_at (loc, opt, - "%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 ()); else warned = warning_at (loc, opt, - "%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 ()); return warned ? opt : no_warning; @@ -1776,9 +1776,9 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict, { auto_diagnostic_group d; if (warning_at (loc, opt, - "%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); @@ -1786,15 +1786,15 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict, } else warned = warning_at (loc, opt, - "%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, - "%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) { @@ -1809,20 +1809,20 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict, if ((ref.basesize < maxobjsize && warning_at (loc, opt, 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, 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), @@ -1833,17 +1833,17 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict, else if (ref.basesize < maxobjsize) warned = warning_at (loc, opt, 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, 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) { @@ -1854,9 +1854,9 @@ maybe_diag_access_bounds (gimple *call, tree func, int strict, type = TYPE_MAIN_VARIANT (type); if (warning_at (loc, opt, - "%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); @@ -1872,10 +1872,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, - "%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 ())) { @@ -2065,7 +2065,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 @@ -2075,8 +2075,8 @@ check_bounds_or_overlap (range_query *query, if (!integer_zerop (dst) && !warning_suppressed_p (call, OPT_Wrestrict)) { 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); suppress_warning (call, OPT_Wrestrict); return OPT_Wrestrict; } |