public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-1147] gimple-ssa-warn-access.cc: add missing auto_diagnostic_group
@ 2022-06-16 21:37 David Malcolm
0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2022-06-16 21:37 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:6ab98d8b58fe4d3c8fce8f34b9efc416b7670c1c
commit r13-1147-g6ab98d8b58fe4d3c8fce8f34b9efc416b7670c1c
Author: David Malcolm <dmalcolm@redhat.com>
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 <dmalcolm@redhat.com>
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",
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-16 21:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-16 21:37 [gcc r13-1147] gimple-ssa-warn-access.cc: add missing auto_diagnostic_group David Malcolm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).