diff options
author | John McCall <rjmccall@apple.com> | 2012-03-30 05:43:39 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2012-03-30 05:43:39 +0000 |
commit | bc15335e580bd29695df04c30d19c3b5a8192552 (patch) | |
tree | dc9442b83ba43c4825b70a9cdfd072b4f82d8be7 /clang | |
parent | e0538b9669149e1d29d6d9b0a5a6ff04f60273fe (diff) | |
download | bcm5719-llvm-bc15335e580bd29695df04c30d19c3b5a8192552.tar.gz bcm5719-llvm-bc15335e580bd29695df04c30d19c3b5a8192552.zip |
Handle placeholder expressions in an ObjC for-collection loop.
The way we handle this implicitly removes the ability to use
property l-values in this position, but that's really okay.
llvm-svn: 153729
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Sema/SemaStmt.cpp | 14 | ||||
-rw-r--r-- | clang/test/SemaObjC/foreach.m | 9 |
2 files changed, 20 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index 39e8a1a1b92..97c8eb04e9e 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -1079,10 +1079,18 @@ Sema::ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, /// x can be an arbitrary l-value expression. Bind it up as a /// full-expression. StmtResult Sema::ActOnForEachLValueExpr(Expr *E) { + // Reduce placeholder expressions here. Note that this rejects the + // use of pseudo-object l-values in this position. + ExprResult result = CheckPlaceholderExpr(E); + if (result.isInvalid()) return StmtError(); + E = result.take(); + CheckImplicitConversions(E); - ExprResult Result = MaybeCreateExprWithCleanups(E); - if (Result.isInvalid()) return StmtError(); - return Owned(static_cast<Stmt*>(Result.get())); + + result = MaybeCreateExprWithCleanups(E); + if (result.isInvalid()) return StmtError(); + + return Owned(static_cast<Stmt*>(result.take())); } ExprResult diff --git a/clang/test/SemaObjC/foreach.m b/clang/test/SemaObjC/foreach.m index c865374e61a..d0e0f7b9e21 100644 --- a/clang/test/SemaObjC/foreach.m +++ b/clang/test/SemaObjC/foreach.m @@ -46,3 +46,12 @@ int main () return 0; } +/* rdar://problem/11068137 */ +@interface Test2 +@property (assign) id prop; +@end +void test2(NSObject<NSFastEnumeration> *collection) { + Test2 *obj; + for (obj.prop in collection) { /* expected-error {{selector element is not a valid lvalue}} */ + } +} |