summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema/SemaStmt.cpp')
-rw-r--r--clang/lib/Sema/SemaStmt.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 619eb772c34..629ab3465dd 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -562,11 +562,18 @@ Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc,
return Diag(VD->getLocation(), diag::err_non_variable_decl_in_for);
if (D->getNextDeclarator())
return Diag(D->getLocation(), diag::err_toomany_element_decls);
- } else
- FirstType = static_cast<Expr*>(first)->getType();
+ } else {
+ Expr::isLvalueResult lval = cast<Expr>(First)->isLvalue(Context);
+
+ if (lval != Expr::LV_Valid)
+ return Diag(First->getLocStart(), diag::err_selector_element_not_lvalue,
+ First->getSourceRange());
+
+ FirstType = static_cast<Expr*>(first)->getType();
+ }
if (!Context.isObjCObjectPointerType(FirstType))
Diag(ForLoc, diag::err_selector_element_type,
- FirstType.getAsString(), First->getSourceRange());
+ FirstType.getAsString(), First->getSourceRange());
}
if (Second) {
DefaultFunctionArrayConversion(Second);
OpenPOWER on IntegriCloud