diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/Wstring-literal-comparison-1.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/Wstring-literal-comparison-1.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/Wstring-literal-comparison-1.c b/gcc/testsuite/gcc.dg/Wstring-literal-comparison-1.c new file mode 100644 index 000000000..97e317644 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wstring-literal-comparison-1.c @@ -0,0 +1,29 @@ +/* PR c/7776 */ +/* { dg-do compile } */ +/* { dg-options "-Waddress" } */ + +int test1(char *ptr) +{ + return ptr == "foo"; /* { dg-warning "comparison with string" } */ +} + +int test2() +{ + return "foo" != (const char*)0; +} + +int test3() +{ + return "foo" == (const char*)0; +} + +int test4() +{ + return (const char*)0 != "foo"; +} + +int test5() +{ + return (const char*)0 == "foo"; +} + |