From 960ecba4bf0515ef3094d68af4d6225f4f11c6d2 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Wed, 11 Jan 2017 18:33:13 +0000 Subject: [PATCH] PR c/47931 - missing -Waddress warning for comparison with NULL gcc/testsuite/ChangeLog: * c-c++-common/Waddress-2.c: New test. From-SVN: r244331 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/c-c++-common/Waddress-2.c | 30 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/Waddress-2.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4df8d41da99..51bcf982f6d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-01-11 Martin Sebor + + PR c/47931 + * c-c++-common/Waddress-2.c: New test. + 2017-01-11 Jakub Jelinek PR c++/78341 diff --git a/gcc/testsuite/c-c++-common/Waddress-2.c b/gcc/testsuite/c-c++-common/Waddress-2.c new file mode 100644 index 00000000000..b58a55fe95f --- /dev/null +++ b/gcc/testsuite/c-c++-common/Waddress-2.c @@ -0,0 +1,30 @@ +/* PR c/47931 - missing -Waddress warning for comparison with NULL + { dg-do compile } + { dg-options "-Waddress" } */ + +#define NULL ((void *) 0) + +int i; + +int f0 (void) +{ + return &i != 0; /* { dg-warning "the address of .i. will never be NULL" } */ +} + +int f1 (void) +{ + return &i != (void *) 0; /* { dg-warning "the address of .i. will never be NULL" } */ +} + +int f2 (void) +{ + return &i != NULL; /* { dg-warning "the address of .i. will never be NULL" } */ +} + +int f3 (void) +{ + return &i != (int *) 0; +} + + + -- 2.30.2