diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-03-22 09:11:14 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-03-22 09:11:14 +0100 |
commit | 4cde512c84dfc20a95a01cca838f288e3015cab5 (patch) | |
tree | d016a7c98c2d31dc41b4d4e32a217406c416f094 /gcc/testsuite | |
parent | 16f6d7dc5c11b0b91aad24b6975dfa77d8e84b6f (diff) | |
download | gcc-4cde512c84dfc20a95a01cca838f288e3015cab5.zip gcc-4cde512c84dfc20a95a01cca838f288e3015cab5.tar.gz gcc-4cde512c84dfc20a95a01cca838f288e3015cab5.tar.bz2 |
re PR c++/70295 (bogus -Wnonnull-compare for "dynamic_cast<const FuSelection *>(this) != nullptr")
PR c++/70295
* gimplify.c (gimplify_modify_expr): Call gimple_set_no_warning
on assign if (*from_p) is a comparison, set it to
TREE_NO_WARNING (*from_p).
* c-c++-common/nonnull-1.c (func): Remove parens around cp4 != 0.
(func2): New function for cond with parens, xfail warning for c++.
* g++.dg/warn/Wnonnull-compare-8.C: New test.
From-SVN: r234392
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/nonnull-1.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wnonnull-compare-8.C | 14 |
3 files changed, 28 insertions, 1 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dc47ef1..25a36dd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2016-03-22 Jakub Jelinek <jakub@redhat.com> + + PR c++/70295 + * c-c++-common/nonnull-1.c (func): Remove parens around cp4 != 0. + (func2): New function for cond with parens, xfail warning for c++. + * g++.dg/warn/Wnonnull-compare-8.C: New test. + 2016-03-22 Patrick Palka <ppalka@gcc.gnu.org> PR c++/70096 diff --git a/gcc/testsuite/c-c++-common/nonnull-1.c b/gcc/testsuite/c-c++-common/nonnull-1.c index fb2814c..2446d6f 100644 --- a/gcc/testsuite/c-c++-common/nonnull-1.c +++ b/gcc/testsuite/c-c++-common/nonnull-1.c @@ -24,5 +24,11 @@ func (char *cp1, char *cp2, char *cp3, char *cp4) if (NULL != cp3) /* { dg-warning "nonnull argument" "cp3 compared to NULL" } */ return 3; - return (cp4 != 0) ? 0 : 1; /* { dg-warning "nonnull argument" "cp4 compared to NULL" } */ + return cp4 != 0 ? 0 : 1; /* { dg-warning "nonnull argument" "cp4 compared to NULL" } */ +} + +__attribute__((nonnull (1))) int +func2 (char *cp) +{ + return (cp != NULL) ? 1 : 0; /* { dg-warning "nonnull argument" "cp compared to NULL" { xfail c++ } } */ } diff --git a/gcc/testsuite/g++.dg/warn/Wnonnull-compare-8.C b/gcc/testsuite/g++.dg/warn/Wnonnull-compare-8.C new file mode 100644 index 0000000..28dcac8 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wnonnull-compare-8.C @@ -0,0 +1,14 @@ +// PR c++/70295 +// { dg-do compile } +// { dg-options "-O2 -Wnonnull-compare" } + +struct A { A (); virtual ~A (); bool foo (bool); }; +struct B : virtual public A { B (); virtual ~B (); }; + +bool +A::foo (bool x) +{ + if (x && dynamic_cast<B *>(this) != (B *) 0) // { dg-bogus "nonnull argument" } + return true; + return false; +} |