From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2209) id 0329C38560A7; Thu, 16 Jun 2022 21:37:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0329C38560A7 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: David Malcolm To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1147] gimple-ssa-warn-access.cc: add missing auto_diagnostic_group X-Act-Checkin: gcc X-Git-Author: David Malcolm X-Git-Refname: refs/heads/master X-Git-Oldrev: d3e0da54c16e5383b9b969b7b40f7eadb35b0b8e X-Git-Newrev: 6ab98d8b58fe4d3c8fce8f34b9efc416b7670c1c Message-Id: <20220616213744.0329C38560A7@sourceware.org> Date: Thu, 16 Jun 2022 21:37:44 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jun 2022 21:37:44 -0000 https://gcc.gnu.org/g:6ab98d8b58fe4d3c8fce8f34b9efc416b7670c1c commit r13-1147-g6ab98d8b58fe4d3c8fce8f34b9efc416b7670c1c Author: David Malcolm Date: Thu Jun 16 17:37:15 2022 -0400 gimple-ssa-warn-access.cc: add missing auto_diagnostic_group Whilst working on SARIF output I noticed some places where followup notes weren't being properly associated with their warnings in gcc/gimple-ssa-warn-access.cc. Fixed thusly. gcc/ChangeLog: * gimple-ssa-warn-access.cc (warn_string_no_nul): Add auto_diagnostic_group to group any warning with its note. (maybe_warn_for_bound): Likewise. (check_access): Likewise. (warn_dealloc_offset): Likewise. (pass_waccess::maybe_warn_memmodel): Likewise. (pass_waccess::maybe_check_dealloc_call): Likewise. (pass_waccess::warn_invalid_pointer): Likewise. (pass_waccess::check_dangling_stores): Likewise. Signed-off-by: David Malcolm Diff: --- gcc/gimple-ssa-warn-access.cc | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc index 00f65858b0c..eb9297a2bb2 100644 --- a/gcc/gimple-ssa-warn-access.cc +++ b/gcc/gimple-ssa-warn-access.cc @@ -160,6 +160,8 @@ warn_string_no_nul (location_t loc, GimpleOrTree expr, const char *fname, (unsigned long long) bndrng[1].to_uhwi ()); } + auto_diagnostic_group d; + const tree maxobjsize = max_object_size (); const wide_int maxsiz = wi::to_wide (maxobjsize); if (expr) @@ -718,6 +720,7 @@ maybe_warn_for_bound (opt_code opt, location_t loc, GimpleOrTree exp, tree func, maybe = false; } + auto_diagnostic_group d; if (tree_int_cst_lt (maxobjsize, bndrng[0])) { if (bndrng[0] == bndrng[1]) @@ -1387,6 +1390,7 @@ check_access (GimpleOrTree exp, tree dstwrite, && warning_suppressed_p (pad->dst.ref, opt))) return false; + auto_diagnostic_group d; location_t loc = get_location (exp); bool warned = false; if (dstwrite == slen && at_least_one) @@ -1505,6 +1509,7 @@ check_access (GimpleOrTree exp, tree dstwrite, const bool read = mode == access_read_only || mode == access_read_write; const bool maybe = pad && pad->dst.parmarray; + auto_diagnostic_group d; if (warn_for_access (loc, func, exp, opt, range, slen, false, read, maybe)) { @@ -2019,6 +2024,7 @@ warn_dealloc_offset (location_t loc, gimple *call, const access_ref &aref) (long long)aref.offrng[1].to_shwi ()); } + auto_diagnostic_group d; if (!warning_at (loc, OPT_Wfree_nonheap_object, "%qD called on pointer %qE with nonzero offset%s", dealloc_decl, aref.ref, offstr)) @@ -2902,6 +2908,7 @@ pass_waccess::maybe_warn_memmodel (gimple *stmt, tree ord_sucs, if (!is_valid) { bool warned = false; + auto_diagnostic_group d; if (const char *modname = memmodel_name (sucs)) warned = warning_at (loc, OPT_Winvalid_memory_model, "invalid memory model %qs for %qD", @@ -2935,6 +2942,7 @@ pass_waccess::maybe_warn_memmodel (gimple *stmt, tree ord_sucs, { /* If both memory model arguments are valid but their combination is not, use their names in the warning. */ + auto_diagnostic_group d; if (!warning_at (loc, OPT_Winvalid_memory_model, "invalid failure memory model %qs for %qD", failname, fndecl)) @@ -2955,6 +2963,7 @@ pass_waccess::maybe_warn_memmodel (gimple *stmt, tree ord_sucs, { /* If both memory model arguments are valid but their combination is not, use their names in the warning. */ + auto_diagnostic_group d; if (!warning_at (loc, OPT_Winvalid_memory_model, "failure memory model %qs cannot be stronger " "than success memory model %qs for %qD", @@ -3684,13 +3693,16 @@ pass_waccess::maybe_check_dealloc_call (gcall *call) if (DECL_P (ref) || EXPR_P (ref)) { /* Diagnose freeing a declared object. */ - if (aref.ref_declared () - && warning_at (loc, OPT_Wfree_nonheap_object, - "%qD called on unallocated object %qD", - dealloc_decl, ref)) + if (aref.ref_declared ()) { - inform (get_location (ref), "declared here"); - return; + auto_diagnostic_group d; + if (warning_at (loc, OPT_Wfree_nonheap_object, + "%qD called on unallocated object %qD", + dealloc_decl, ref)) + { + inform (get_location (ref), "declared here"); + return; + } } /* Diagnose freeing a pointer that includes a positive offset. @@ -3702,6 +3714,7 @@ pass_waccess::maybe_check_dealloc_call (gcall *call) } else if (CONSTANT_CLASS_P (ref)) { + auto_diagnostic_group d; if (warning_at (loc, OPT_Wfree_nonheap_object, "%qD called on a pointer to an unallocated " "object %qE", dealloc_decl, ref)) @@ -3904,6 +3917,7 @@ pass_waccess::warn_invalid_pointer (tree ref, gimple *use_stmt, const tree inval_decl = gimple_call_fndecl (inval_stmt); + auto_diagnostic_group d; if ((ref && warning_at (use_loc, OPT_Wuse_after_free, (maybe ? G_("pointer %qE may be used after %qD") @@ -3929,6 +3943,7 @@ pass_waccess::warn_invalid_pointer (tree ref, gimple *use_stmt, if (DECL_NAME (var)) { + auto_diagnostic_group d; if ((ref && warning_at (use_loc, OPT_Wdangling_pointer_, (maybe @@ -4576,6 +4591,7 @@ pass_waccess::check_dangling_stores (basic_block bb, if (!is_auto_decl (rhs_ref.ref)) continue; + auto_diagnostic_group d; location_t loc = gimple_location (stmt); if (warning_at (loc, OPT_Wdangling_pointer_, "storing the address of local variable %qD in %qE",