aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-ssa-warn-access.cc
diff options
context:
space:
mode:
authorMartin Uecker <uecker@tugraz.at>2023-07-27 13:41:33 +0200
committerMartin Uecker <uecker@tugraz.at>2023-11-11 10:37:46 +0100
commitc58b426d64ac2513dc0ed19165740604e891e9df (patch)
treefb0ed672a677d1053af234821420b7460cd61504 /gcc/gimple-ssa-warn-access.cc
parent391f9798b35ec75c1a49fb04610db5ab347e9d0d (diff)
downloadgcc-c58b426d64ac2513dc0ed19165740604e891e9df.zip
gcc-c58b426d64ac2513dc0ed19165740604e891e9df.tar.gz
gcc-c58b426d64ac2513dc0ed19165740604e891e9df.tar.bz2
c: Synthesize nonnull attribute for parameters declared with static [PR110815]
Parameters declared with `static` are nonnull. We synthesize an artifical nonnull attribute for such parameters to get the same warnings and optimizations. Bootstrapped and regression tested on x86. PR c/110815 PR c/112428 gcc/c-family: * c-attribs.cc (build_attr_access_from_parms): Synthesize nonnull attribute for parameters declared with `static`. gcc: * gimple-ssa-warn-access.cc (pass_waccess::maybe_check_access_sizes): remove warning for parameters declared with `static`. gcc/testsuite: * gcc.dg/Wnonnull-8.c: Adapt test. * gcc.dg/Wnonnull-9.c: New test.
Diffstat (limited to 'gcc/gimple-ssa-warn-access.cc')
-rw-r--r--gcc/gimple-ssa-warn-access.cc10
1 files changed, 0 insertions, 10 deletions
diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc
index 8b73429..da2e3fe 100644
--- a/gcc/gimple-ssa-warn-access.cc
+++ b/gcc/gimple-ssa-warn-access.cc
@@ -3491,16 +3491,6 @@ pass_waccess::maybe_check_access_sizes (rdwr_map *rwm, tree fndecl, tree fntype,
ptridx + 1, sizidx + 1, sizstr))
arg_warned = OPT_Wnonnull;
}
- else if (access_size && access.second.static_p)
- {
- /* Warn about null pointers for [static N] array arguments
- but do not warn for ordinary (i.e., nonstatic) arrays. */
- if (warning_at (loc, OPT_Wnonnull,
- "argument %i to %<%T[static %E]%> "
- "is null where non-null expected",
- ptridx + 1, argtype, access_nelts))
- arg_warned = OPT_Wnonnull;
- }
if (arg_warned != no_warning)
{