diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2009-03-22 23:26:56 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2009-03-22 23:26:56 +0000 |
| commit | e8dd7b32282b6f89b28ba66a8794227e02257a12 (patch) | |
| tree | fddab073e834b3a9a52d7641c39b38cc3390533d /clang/lib/AST/Expr.cpp | |
| parent | d8500f3b0f54c6b29640e524c6b660f20fc7cf3f (diff) | |
| download | bcm5719-llvm-e8dd7b32282b6f89b28ba66a8794227e02257a12.tar.gz bcm5719-llvm-e8dd7b32282b6f89b28ba66a8794227e02257a12.zip | |
Adjust isModifiableLvalue to give a slightly more useful diagnostic for
attempting to illegally modify a BlockDeclRefExpr.
llvm-svn: 67491
Diffstat (limited to 'clang/lib/AST/Expr.cpp')
| -rw-r--r-- | clang/lib/AST/Expr.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index f2553c3390d..789fbc5ce1d 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -781,7 +781,17 @@ Expr::isModifiableLvalueResult Expr::isModifiableLvalue(ASTContext &Ctx) const { 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 @@ Expr::isModifiableLvalueResult Expr::isModifiableLvalue(ASTContext &Ctx) const { 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) { |

