From: Martin Sebor Date: Wed, 11 Jan 2017 18:33:13 +0000 (+0000) Subject: PR c/47931 - missing -Waddress warning for comparison with NULL X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=960ecba4bf0515ef3094d68af4d6225f4f11c6d2;p=gcc.git PR c/47931 - missing -Waddress warning for comparison with NULL gcc/testsuite/ChangeLog: * c-c++-common/Waddress-2.c: New test. From-SVN: r244331 --- 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; +} + + +