[cfe-commits] r93883 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaObjC/property-user-setter.m

Fariborz Jahanian fjahanian at apple.com
Tue Jan 19 09:48:03 PST 2010


Author: fjahanian
Date: Tue Jan 19 11:48:02 2010
New Revision: 93883

URL: http://llvm.org/viewvc/llvm-project?rev=93883&view=rev
Log:
Issue diagnostics (instead of crashing in code gen) when using
property dot-syntax notation to use setter/getters in objective-c. 
Fixes radar 7553050.


Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/SemaObjC/property-user-setter.m

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=93883&r1=93882&r2=93883&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jan 19 11:48:02 2010
@@ -3082,15 +3082,9 @@
     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));
     }

Modified: cfe/trunk/test/SemaObjC/property-user-setter.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-user-setter.m?rev=93883&r1=93882&r2=93883&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/property-user-setter.m (original)
+++ cfe/trunk/test/SemaObjC/property-user-setter.m Tue Jan 19 11:48:02 2010
@@ -80,11 +80,24 @@
 }
 @end
 
+ at interface C {}
+// - (int)Foo;
+- (void)setFoo:(int)value;
+ at 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;





More information about the cfe-commits mailing list