re PR sanitizer/79572 (reference binding to null pointer not reported with -fsanitize...
authorJakub Jelinek <jakub@redhat.com>
Fri, 31 Mar 2017 18:39:25 +0000 (20:39 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 31 Mar 2017 18:39:25 +0000 (20:39 +0200)
commit6f3af3562804db0ef656dcc02b1e192c8f7fc8cc
treebcd8eeb5904c373580e8d225e212003161cc8d72
parent77734296b4b2634ea4b0222cc5d829d0eb99825f
re PR sanitizer/79572 (reference binding to null pointer not reported with -fsanitize=undefined)

PR c++/79572
* c-ubsan.h (ubsan_maybe_instrument_reference): Change argument to
tree *.
* c-ubsan.c (ubsan_maybe_instrument_reference): Likewise.  Handle
not just NOP_EXPR to REFERENCE_TYPE, but also INTEGER_CST with
REFERENCE_TYPE.

* cp-gimplify.c (cp_genericize_r): Sanitize INTEGER_CSTs with
REFERENCE_TYPE.  Adjust ubsan_maybe_instrument_reference caller
for NOP_EXPR to REFERENCE_TYPE.

* g++.dg/ubsan/null-8.C: New test.

From-SVN: r246621
gcc/c-family/ChangeLog
gcc/c-family/c-ubsan.c
gcc/c-family/c-ubsan.h
gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ubsan/null-8.C [new file with mode: 0644]