]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/cp/init.c
re PR c++/69922 (Bogus -Wnonnull-compare for: ... ? static_cast<T*>(this) : nullptr)
authorJakub Jelinek <jakub@redhat.com>
Wed, 24 Feb 2016 22:01:24 +0000 (23:01 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 24 Feb 2016 22:01:24 +0000 (23:01 +0100)
commit03ca8fb3da94f12e5cd2ba57373d3875cd8d8cf8
treeaa66bb95b65b601ee8e6a8fef70163aacf5b9226
parent0b05329bbfaade628e97f5d33165f82337865153
re PR c++/69922 (Bogus -Wnonnull-compare for: ... ? static_cast<T*>(this) : nullptr)

PR c++/69922
* class.c (build_base_path): Set TREE_NO_WARNING on the null_test.
Avoid folding it.
* init.c (build_vec_delete_1, build_delete): Don't fold the non-NULL
tests.
* cp-gimplify.c (cp_fold): For TREE_NO_WARNING comparisons with NULL,
unless they are folded into INTEGER_CST, error_mark_node or some
comparison with NULL, avoid folding them and use either the original
comparison or non-folded comparison of folded arguments.
* cp-ubsan.c (cp_ubsan_instrument_vptr): Set TREE_NO_WARNING on the
comparison, don't fold the comparison right away.

* g++.dg/warn/Wnonnull-compare-6.C: New test.
* g++.dg/warn/Wnonnull-compare-7.C: New test.
* g++.dg/ubsan/pr69922.C: New test.

From-SVN: r233684
gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/cp-gimplify.c
gcc/cp/cp-ubsan.c
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ubsan/pr69922.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/Wnonnull-compare-6.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/Wnonnull-compare-7.C [new file with mode: 0644]