aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.cc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2024-11-28 11:50:49 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2024-11-28 11:50:49 +0100
commit912d5cfb8cf3c2568a544a4260bac4f6f932767a (patch)
tree4e87a8a4d5101ffa3dfd52b6f31d96e8a2267aca /gcc/expr.cc
parent19fe55c4801de50deee03b333e94d007aae222e3 (diff)
downloadgcc-912d5cfb8cf3c2568a544a4260bac4f6f932767a.zip
gcc-912d5cfb8cf3c2568a544a4260bac4f6f932767a.tar.gz
gcc-912d5cfb8cf3c2568a544a4260bac4f6f932767a.tar.bz2
ranger: Handle nonnull_if_nonzero attribute [PR117023]
On top of the https://gcc.gnu.org/pipermail/gcc-patches/2024-November/668554.html patch which introduces the nonnull_if_nonzero attribute (because C2Y is allowing NULL arguments on various calls like memcpy, memset, strncpy etc. as long as the count is 0) the following patch adds just limited handling of the attribute in the ranger, in particular infers nonnull for the pointer argument referenced in first argument of the attribute if the second argument is a non-zero INTEGER_CST (integer_nonzerop). Ideally (as the FIXME says) I'd like to query arg2 range and check if it doesn't contain zero, but am not sure such queries are possible from gimple_infer_range (and if it is possible whether one can just query the currently recorded range for it or if one can call something that will try to compute the range by walking the def stmts etc.). Could you handle as a follow-up the range querying if it is possible? As for useful testcase, with the patch I'm going to post next e.g. gcc.dg/tree-ssa/pr78154.c if the calls use d as destination (not dn) and count that will have a range which doesn't include 0 and isn't constant. 2024-11-28 Jakub Jelinek <jakub@redhat.com> PR c/117023 * gimple-range-infer.cc (gimple_infer_range::gimple_infer_range): Handle also nonnull_if_nonzero attributes.
Diffstat (limited to 'gcc/expr.cc')
0 files changed, 0 insertions, 0 deletions