summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-12-04 03:47:34 +0000
committerJohn McCall <rjmccall@apple.com>2010-12-04 03:47:34 +0000
commit34376a68c414ccf372e9d83f3251ecb08eb055f2 (patch)
tree336b12526893f3694b8cb5654fef621818daca81 /clang/lib/Sema/SemaStmt.cpp
parent1c8ac8f027d4a7af830e91513f37a2139c684f19 (diff)
downloadbcm5719-llvm-34376a68c414ccf372e9d83f3251ecb08eb055f2.tar.gz
bcm5719-llvm-34376a68c414ccf372e9d83f3251ecb08eb055f2.zip
Although we currently have explicit lvalue-to-rvalue conversions, they're
not actually frequently used, because ImpCastExprToType only creates a node if the types differ. So explicitly create an ICE in the lvalue-to-rvalue conversion code in DefaultFunctionArrayLvalueConversion() as well as several other new places, and consistently deal with the consequences throughout the compiler. In addition, introduce a new cast kind for loading an ObjCProperty l-value, and make sure we emit those nodes whenever an ObjCProperty l-value appears that's not on the LHS of an assignment operator. This breaks a couple of rewriter tests, which I've x-failed until future development occurs on the rewriter. Ted Kremenek kindly contributed the analyzer workarounds in this patch. llvm-svn: 120890
Diffstat (limited to 'clang/lib/Sema/SemaStmt.cpp')
-rw-r--r--clang/lib/Sema/SemaStmt.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 7fa555e4f90..7ab30d16214 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -92,7 +92,7 @@ void Sema::DiagnoseUnusedExprResult(const Stmt *S) {
if (const CXXExprWithTemporaries *Temps = dyn_cast<CXXExprWithTemporaries>(E))
E = Temps->getSubExpr();
- E = E->IgnoreParens();
+ E = E->IgnoreParenImpCasts();
if (const CallExpr *CE = dyn_cast<CallExpr>(E)) {
if (E->getType()->isVoidType())
return;
@@ -952,6 +952,17 @@ Sema::ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc,
RParenLoc));
}
+/// In an Objective C collection iteration statement:
+/// for (x in y)
+/// x can be an arbitrary l-value expression. Bind it up as a
+/// full-expression.
+StmtResult Sema::ActOnForEachLValueExpr(Expr *E) {
+ CheckImplicitConversions(E);
+ ExprResult Result = MaybeCreateCXXExprWithTemporaries(E);
+ if (Result.isInvalid()) return StmtError();
+ return Owned(static_cast<Stmt*>(Result.get()));
+}
+
StmtResult
Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc,
SourceLocation LParenLoc,
@@ -1228,6 +1239,10 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) {
unsigned D = diag::ext_return_has_expr;
if (RetValExp->getType()->isVoidType())
D = diag::ext_return_has_void_expr;
+ else {
+ IgnoredValueConversions(RetValExp);
+ ImpCastExprToType(RetValExp, Context.VoidTy, CK_ToVoid);
+ }
// return (some void expression); is legal in C++.
if (D != diag::ext_return_has_void_expr ||
OpenPOWER on IntegriCloud