Created
March 31, 2012 21:46
-
-
Save PsychoH13/2268849 to your computer and use it in GitHub Desktop.
New Diagnostic in Clang: -Wimplicit-pointer-condition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @class MyClass; | |
| int main(int argc, char *argv[]) | |
| { | |
| void *obj = nil; | |
| if(obj) {} | |
| if((obj)) {} | |
| for(void *var; var;) {} | |
| while(obj) {} | |
| while(obj != 0) {} | |
| id var = nil; | |
| while(var) {} | |
| while((var)) {} | |
| MyClass *myClass = nil; | |
| MyClass **myClassPtr = &myClass; | |
| if(myClass) {} | |
| if(*myClassPtr) {} | |
| void (^blk)(void); | |
| if(blk) {} | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ./clang ~/test.m -Wimplicit-pointer-condition -fsyntax-only | |
| /Users/remydemarest/test.m:7:5: warning: using pointer expression as condition [-Wimplicit-pointer-condition] | |
| if(obj) {} | |
| ^ ~~~ | |
| /Users/remydemarest/test.m:11:5: warning: using pointer expression as condition [-Wimplicit-pointer-condition] | |
| for(void *var; var;) {} | |
| ^ ~~~ | |
| /Users/remydemarest/test.m:13:5: warning: using pointer expression as condition [-Wimplicit-pointer-condition] | |
| while(obj) {} | |
| ^ ~~~ | |
| /Users/remydemarest/test.m:19:5: warning: using pointer expression as condition [-Wimplicit-pointer-condition] | |
| while(var) {} | |
| ^ ~~~ | |
| /Users/remydemarest/test.m:26:5: warning: using pointer expression as condition [-Wimplicit-pointer-condition] | |
| if(myClass) {} | |
| ^ ~~~~~~~ | |
| /Users/remydemarest/test.m:27:5: warning: using pointer expression as condition [-Wimplicit-pointer-condition] | |
| if(*myClassPtr) {} | |
| ^ ~~~~~~~~~~~ | |
| /Users/remydemarest/test.m:31:5: warning: using pointer expression as condition [-Wimplicit-pointer-condition] | |
| if(blk) {} | |
| ^ ~~~ | |
| 7 warnings generated. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment