Adjust isModifiableLvalue to give a slightly more useful diagnostic for
attempting to illegally modify a BlockDeclRefExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67491 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index f2553c3..789fbc5 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -781,7 +781,17 @@
return MLV_InvalidExpression;
case LV_MemberFunction: return MLV_MemberFunction;
}
-
+
+ // The following is illegal:
+ // void takeclosure(void (^C)(void));
+ // void func() { int x = 1; takeclosure(^{ x = 7; }); }
+ //
+ if (getStmtClass() == BlockDeclRefExprClass) {
+ const BlockDeclRefExpr *BDR = cast<BlockDeclRefExpr>(this);
+ if (!BDR->isByRef() && isa<VarDecl>(BDR->getDecl()))
+ return MLV_NotBlockQualified;
+ }
+
QualType CT = Ctx.getCanonicalType(getType());
if (CT.isConstQualified())
@@ -795,15 +805,6 @@
if (r->hasConstFields())
return MLV_ConstQualified;
}
- // The following is illegal:
- // void takeclosure(void (^C)(void));
- // void func() { int x = 1; takeclosure(^{ x = 7 }); }
- //
- if (getStmtClass() == BlockDeclRefExprClass) {
- const BlockDeclRefExpr *BDR = cast<BlockDeclRefExpr>(this);
- if (!BDR->isByRef() && isa<VarDecl>(BDR->getDecl()))
- return MLV_NotBlockQualified;
- }
// Assigning to an 'implicit' property?
else if (getStmtClass() == ObjCKVCRefExprClass) {