[cfe-commits] r81769 - in /cfe/trunk: lib/AST/Expr.cpp test/SemaObjC/property-error-readonly-assign.m
Fariborz Jahanian
fjahanian at apple.com
Mon Sep 14 09:40:48 PDT 2009
Author: fjahanian
Date: Mon Sep 14 11:40:48 2009
New Revision: 81769
URL: http://llvm.org/viewvc/llvm-project?rev=81769&view=rev
Log:
Using the property dot-syntax to invoke a non-eixsting
structure-valued setter should cause a user error instead of
crash.
Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/test/SemaObjC/property-error-readonly-assign.m
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=81769&r1=81768&r2=81769&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Mon Sep 14 11:40:48 2009
@@ -1061,12 +1061,18 @@
// void takeclosure(void (^C)(void));
// void func() { int x = 1; takeclosure(^{ x = 7; }); }
//
- if (isa<BlockDeclRefExpr>(this)) {
- const BlockDeclRefExpr *BDR = cast<BlockDeclRefExpr>(this);
+ if (const BlockDeclRefExpr *BDR = dyn_cast<BlockDeclRefExpr>(this)) {
if (!BDR->isByRef() && isa<VarDecl>(BDR->getDecl()))
return MLV_NotBlockQualified;
}
-
+
+ // Assigning to an 'implicit' property?
+ if (const ObjCImplicitSetterGetterRefExpr* Expr =
+ dyn_cast<ObjCImplicitSetterGetterRefExpr>(this)) {
+ if (Expr->getSetterMethod() == 0)
+ return MLV_NoSetterProperty;
+ }
+
QualType CT = Ctx.getCanonicalType(getType());
if (CT.isConstQualified())
@@ -1081,13 +1087,6 @@
return MLV_ConstQualified;
}
- // Assigning to an 'implicit' property?
- else if (isa<ObjCImplicitSetterGetterRefExpr>(this)) {
- const ObjCImplicitSetterGetterRefExpr* Expr =
- cast<ObjCImplicitSetterGetterRefExpr>(this);
- if (Expr->getSetterMethod() == 0)
- return MLV_NoSetterProperty;
- }
return MLV_Valid;
}
Modified: cfe/trunk/test/SemaObjC/property-error-readonly-assign.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-error-readonly-assign.m?rev=81769&r1=81768&r2=81769&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/property-error-readonly-assign.m (original)
+++ cfe/trunk/test/SemaObjC/property-error-readonly-assign.m Mon Sep 14 11:40:48 2009
@@ -19,3 +19,26 @@
b.ok = 20;
}
+typedef struct {
+ int i1, i2;
+} NSRect;
+
+NSRect NSMakeRect();
+
+ at interface NSWindow
+{
+ NSRect _frame;
+}
+- (NSRect)frame;
+ at end
+
+ at interface NSWindow (Category)
+-(void)methodToMakeClangCrash;
+ at end
+
+ at implementation NSWindow (Category)
+-(void)methodToMakeClangCrash
+{
+ self.frame = NSMakeRect(); // expected-error {{setter method is needed to assign to object using property assignment syntax}}
+}
+ at end
More information about the cfe-commits
mailing list