From: Chris Lattner Date: Wed, 26 Sep 2007 22:06:30 +0000 (+0000) Subject: objc messages have side effects, return true from hasLocalSideEffect, X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a9c01021724b9b546d282b8609cbe559734812ec;p=clang objc messages have side effects, return true from hasLocalSideEffect, fixing: VoidMethod.m:14:5: warning: expression result unused [Greeter hello]; ^~~~~~~~~~~~~~~ git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42380 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/AST/Expr.cpp b/AST/Expr.cpp index ffd2d3e8d5..0b1c7994ff 100644 --- a/AST/Expr.cpp +++ b/AST/Expr.cpp @@ -259,6 +259,8 @@ bool Expr::hasLocalSideEffect() const { // TODO: check attributes for pure/const. "void foo() { strlen("bar"); }" // should warn. return true; + case ObjCMessageExprClass: + return true; case CastExprClass: // If this is a cast to void, check the operand. Otherwise, the result of diff --git a/clang.xcodeproj/project.pbxproj b/clang.xcodeproj/project.pbxproj index fca0464b47..04dad73923 100644 --- a/clang.xcodeproj/project.pbxproj +++ b/clang.xcodeproj/project.pbxproj @@ -733,7 +733,6 @@ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */; - compatibilityVersion = "Xcode 2.4"; hasScannedForEncodings = 1; mainGroup = 08FB7794FE84155DC02AAC07 /* clang */; projectDirPath = ""; diff --git a/test/Sema/objc-unused.m b/test/Sema/objc-unused.m new file mode 100644 index 0000000000..cbe15a1abb --- /dev/null +++ b/test/Sema/objc-unused.m @@ -0,0 +1,18 @@ +// RUN: clang %s -verify -fsyntax-only +#include + +@interface Greeter ++ (void) hello; +@end + +@implementation Greeter ++ (void) hello { + fprintf(stdout, "Hello, World!\n"); +} +@end + +int main (void) { + [Greeter hello]; + return 0; +} +