]> granicus.if.org Git - clang/commitdiff
Issue diagnostics (instead of crashing in code gen) when using
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 19 Jan 2010 17:48:02 +0000 (17:48 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 19 Jan 2010 17:48:02 +0000 (17:48 +0000)
property dot-syntax notation to use setter/getters in objective-c.
Fixes radar 7553050.

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

lib/Sema/SemaExpr.cpp
test/SemaObjC/property-user-setter.m

index eaf392116fdbe6c7506b4e87cd26ab69f842e88b..f8f3e05f56e5722ad18b2ff29acbfa373574abe0 100644 (file)
@@ -3082,15 +3082,9 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr,
     if (Setter && DiagnoseUseOfDecl(Setter, MemberLoc))
       return ExprError();
 
-    if (Getter || Setter) {
+    if (Getter) {
       QualType PType;
-
-      if (Getter)
-        PType = Getter->getResultType();
-      else
-        // Get the expression type from Setter's incoming parameter.
-        PType = (*(Setter->param_end() -1))->getType();
-      // FIXME: we must check that the setter has property type.
+      PType = Getter->getResultType();
       return Owned(new (Context) ObjCImplicitSetterGetterRefExpr(Getter, PType,
                                       Setter, MemberLoc, BaseExpr));
     }
index c06f2b6f44fbd5555b3f3d539d9f8f4b20acafb6..babccee4a7f04cd8e5f944f5dc8e2b40fa04db9e 100644 (file)
@@ -80,11 +80,24 @@ static int g_val;
 }
 @end
 
+@interface C {}
+// - (int)Foo;
+- (void)setFoo:(int)value;
+@end
+
+void g(int);
+
+void f(C *c) {
+    c.Foo = 17; // expected-error {{property 'Foo' not found on object of type 'C *'}}
+    g(c.Foo); // expected-error {{property 'Foo' not found on object of type 'C *'}}
+}
+
+
 void abort(void);
 int main (void) {
     Subclass *x = [[Subclass alloc] init];
 
-    x.setterOnly = 4;
+    x.setterOnly = 4;  // expected-error {{property 'setterOnly' not found on object of type 'Subclass *'}}
     if (g_val != 4)
       abort ();
     return 0;