diff options
author | dberlin <dberlin@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-12-06 16:54:04 +0000 |
---|---|---|
committer | dberlin <dberlin@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-12-06 16:54:04 +0000 |
commit | 0aa57f28eba75992b3f38d970777597851fdc13f (patch) | |
tree | 85f1e092f35883724bee0eb28f5d10a4ddaaed4b /gcc/testsuite/g++.dg/warn/Wstring-literal-comparison-2.C | |
parent | f575b079a16669e42ddb0d40a0779fea73362f0a (diff) |
Merge from mainline
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/dataflow-branch@108122 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/g++.dg/warn/Wstring-literal-comparison-2.C')
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wstring-literal-comparison-2.C | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/warn/Wstring-literal-comparison-2.C b/gcc/testsuite/g++.dg/warn/Wstring-literal-comparison-2.C new file mode 100644 index 00000000000..3eb91eeca49 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wstring-literal-comparison-2.C @@ -0,0 +1,29 @@ +/* PR c/7776 */ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ + +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"; +} + |