[cfe-commits] r153729 - in /cfe/trunk: lib/Sema/SemaStmt.cpp test/SemaObjC/foreach.m
John McCall
rjmccall at apple.com
Thu Mar 29 22:43:39 PDT 2012
Author: rjmccall
Date: Fri Mar 30 00:43:39 2012
New Revision: 153729
URL: http://llvm.org/viewvc/llvm-project?rev=153729&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/SemaObjC/foreach.m
Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=153729&r1=153728&r2=153729&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Fri Mar 30 00:43:39 2012
@@ -1079,10 +1079,18 @@
/// 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
Modified: cfe/trunk/test/SemaObjC/foreach.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/foreach.m?rev=153729&r1=153728&r2=153729&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/foreach.m (original)
+++ cfe/trunk/test/SemaObjC/foreach.m Fri Mar 30 00:43:39 2012
@@ -46,3 +46,12 @@
return 0;
}
+/* rdar://problem/11068137 */
+ at interface Test2
+ at property (assign) id prop;
+ at end
+void test2(NSObject<NSFastEnumeration> *collection) {
+ Test2 *obj;
+ for (obj.prop in collection) { /* expected-error {{selector element is not a valid lvalue}} */
+ }
+}
More information about the cfe-commits
mailing list