]> granicus.if.org Git - clang/commitdiff
Support for objc use of property-dot syntax as receiver
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 8 Feb 2011 00:23:07 +0000 (00:23 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 8 Feb 2011 00:23:07 +0000 (00:23 +0000)
in liu of a class method getter. objc++ uses a different
code path and is more involved (TBD).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125061 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprObjC.cpp
test/SemaObjC/property-dot-receiver.m [new file with mode: 0644]

index eeaa45163d54c8761c2a992ab31ebf43596a4009..11fa9eb0b4293c633758591210cf454fe5300911 100644 (file)
@@ -675,6 +675,10 @@ Sema::ObjCMessageKind Sema::getObjCMessageKind(Scope *S,
     return ObjCInstanceMessage;
 
   case LookupResult::Found: {
+    // If the identifier is a class or not, and there is a trailing dot,
+    // it's an instance message.
+    if (HasTrailingDot)
+      return ObjCInstanceMessage;
     // We found something. If it's a type, then we have a class
     // message. Otherwise, it's an instance message.
     NamedDecl *ND = Result.getFoundDecl();
diff --git a/test/SemaObjC/property-dot-receiver.m b/test/SemaObjC/property-dot-receiver.m
new file mode 100644 (file)
index 0000000..3498dcc
--- /dev/null
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s 
+// rdar://8962253
+
+@interface Singleton {
+}
++ (Singleton*) instance;
+@end
+
+@implementation Singleton
+
+- (void) someSelector { }
+
++ (Singleton*) instance { return 0; }
+
++ (void) compileError
+{
+     [Singleton.instance  someSelector]; // clang issues error here
+}
+
+@end
+