]> git.ipfire.org Git - thirdparty/gcc.git/commit
Reset PHI base0 flag if it's clear in any argument [PR101977, ...]
authorMartin Sebor <msebor@redhat.com>
Tue, 24 Aug 2021 16:49:11 +0000 (10:49 -0600)
committerMartin Sebor <msebor@redhat.com>
Tue, 24 Aug 2021 16:49:11 +0000 (10:49 -0600)
commit820f0940d7ace1306430a9dcf1bd9577508a7a7e
treeb9517cd7a654bf06337532a5395539c4eaa6c55e
parent6d692ef43b2b3368c92c3fb757c7884fc94ee627
Reset PHI base0 flag if it's clear in any argument [PR101977, ...]

Resolves:
PR middle-end/101600 - Spurious -Warray-bounds downcasting a polymorphic pointer
PR middle-end/101977 - bogus -Warray-bounds on a negative index into a parameter in conditional with null

gcc/ChangeLog:

PR middle-end/101600
PR middle-end/101977
* gimple-ssa-warn-access.cc (maybe_warn_for_bound): Tighten up
the phrasing of a warning.
(check_access): Use the remaining size after subtracting any offset
rather than the whole object size.
* pointer-query.cc (access_ref::get_ref): Clear BASE0 flag if it's
clear for any nonnull PHI argument.
(compute_objsize): Clear argument.

gcc/testsuite/ChangeLog:

PR middle-end/101600
PR middle-end/101977
* g++.dg/pr100574.C: Prune out valid warning.
* gcc.dg/pr20126.c: Same.
* gcc.dg/Wstringop-overread.c: Adjust text of expected warnings.
Add new instances.
* gcc.dg/warn-strnlen-no-nul.c: Same.
* g++.dg/warn/Warray-bounds-26.C: New test.
* gcc.dg/Warray-bounds-88.c: New test.
gcc/gimple-ssa-warn-access.cc
gcc/pointer-query.cc
gcc/testsuite/g++.dg/pr100574.C
gcc/testsuite/g++.dg/warn/Warray-bounds-26.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/Warray-bounds-88.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wstringop-overread.c
gcc/testsuite/gcc.dg/pr20126.c
gcc/testsuite/gcc.dg/warn-strnlen-no-nul.c