]> granicus.if.org Git - clang/commitdiff
objc messages have side effects, return true from hasLocalSideEffect,
authorChris Lattner <sabre@nondot.org>
Wed, 26 Sep 2007 22:06:30 +0000 (22:06 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 26 Sep 2007 22:06:30 +0000 (22:06 +0000)
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

AST/Expr.cpp
clang.xcodeproj/project.pbxproj
test/Sema/objc-unused.m [new file with mode: 0644]

index ffd2d3e8d550f33716d9054930ea4a0a99eeac05..0b1c7994fffbde3b74f28e07417d26f010332eb5 100644 (file)
@@ -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
index fca0464b4752d414dd76727fe5bf5bd18bc2ddca..04dad73923642fe8370e14e246e86154e9d98bb5 100644 (file)
                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 (file)
index 0000000..cbe15a1
--- /dev/null
@@ -0,0 +1,18 @@
+// RUN: clang %s -verify -fsyntax-only
+#include <stdio.h>
+
+@interface Greeter
++ (void) hello;
+@end
+
+@implementation Greeter
++ (void) hello {
+    fprintf(stdout, "Hello, World!\n");
+}
+@end
+
+int main (void) {
+    [Greeter hello];
+    return 0;
+}
+