aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-ssa-warn-access.cc
diff options
context:
space:
mode:
authorMartin Uecker <uecker@tugraz.at>2023-04-13 19:35:15 +0200
committerMartin Uecker <uecker@tugraz.at>2023-11-03 23:20:39 +0100
commit6e9ee44d96e5bda8808dd9d8ccf58d2525383f6b (patch)
tree357a172ed0e579530aad437cedb5e702c35fdbdc /gcc/gimple-ssa-warn-access.cc
parent5340f48b7639fcc874f64aac214f9ef9ae43d43e (diff)
downloadgcc-6e9ee44d96e5bda8808dd9d8ccf58d2525383f6b.zip
gcc-6e9ee44d96e5bda8808dd9d8ccf58d2525383f6b.tar.gz
gcc-6e9ee44d96e5bda8808dd9d8ccf58d2525383f6b.tar.bz2
Reduce false positives for -Wnonnull for VLA parameters [PR98541]
This patch limits the warning about NULL arguments to VLA parameters declared [static n]. PR c/98541 gcc/ * gimple-ssa-warn-access.cc (pass_waccess::maybe_check_access_sizes): For VLA bounds in parameters, only warn about null pointers with 'static'. gcc/testsuite: * gcc.dg/Wnonnull-4.c: Adapt test. * gcc.dg/Wstringop-overflow-40.c: Adapt test.
Diffstat (limited to 'gcc/gimple-ssa-warn-access.cc')
-rw-r--r--gcc/gimple-ssa-warn-access.cc19
1 files changed, 3 insertions, 16 deletions
diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc
index e439d1b..8b73429 100644
--- a/gcc/gimple-ssa-warn-access.cc
+++ b/gcc/gimple-ssa-warn-access.cc
@@ -3477,27 +3477,14 @@ pass_waccess::maybe_check_access_sizes (rdwr_map *rwm, tree fndecl, tree fntype,
if (integer_zerop (ptr))
{
- if (sizidx >= 0 && tree_int_cst_sgn (sizrng[0]) > 0)
+ if (!access.second.internal_p
+ && sizidx >= 0 && tree_int_cst_sgn (sizrng[0]) > 0)
{
/* Warn about null pointers with positive sizes. This is
different from also declaring the pointer argument with
attribute nonnull when the function accepts null pointers
only when the corresponding size is zero. */
- if (access.second.internal_p)
- {
- const std::string argtypestr
- = access.second.array_as_string (ptrtype);
-
- if (warning_at (loc, OPT_Wnonnull,
- "argument %i of variable length "
- "array %s is null but "
- "the corresponding bound argument "
- "%i value is %s",
- ptridx + 1, argtypestr.c_str (),
- sizidx + 1, sizstr))
- arg_warned = OPT_Wnonnull;
- }
- else if (warning_at (loc, OPT_Wnonnull,
+ if (warning_at (loc, OPT_Wnonnull,
"argument %i is null but "
"the corresponding size argument "
"%i value is %s",