aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-04-17 00:09:41 +0000
committerMike Stump <mrs@apple.com>2009-04-17 00:09:41 +0000
commit397195bf3077fb42789b326f69f7d417227a0588 (patch)
tree462c4f4a1e2977dcfbaa0b6a99d1b9a620d88e43 /lib
parentb14095aa98c6fedd3625920c4ce834bcaf24d9f7 (diff)
Fixup semantic analysis for nested blocks, and allow block literal
expressions that can be of static duration to be returned. Radar 6786551 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69331 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Sema/SemaChecking.cpp5
-rw-r--r--lib/Sema/SemaExpr.cpp5
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 827f63cfcd..8e3a4212e0 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -872,8 +872,9 @@ Sema::CheckReturnStackAddr(Expr *RetValExp, QualType lhsType,
RetValExp = IcExpr->getSubExpr();
if (BlockExpr *C = dyn_cast_or_null<BlockExpr>(RetValExp))
- Diag(C->getLocStart(), diag::err_ret_local_block)
- << C->getSourceRange();
+ if (C->hasBlockDeclRefExprs())
+ Diag(C->getLocStart(), diag::err_ret_local_block)
+ << C->getSourceRange();
}
// Perform checking for stack values returned by reference.
else if (lhsType->isReferenceType()) {
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index f903e8f253..e0d28fa140 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -4774,6 +4774,11 @@ Sema::OwningExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
if (BSI->ReturnType)
RetTy = QualType(BSI->ReturnType, 0);
+ // A reference in a nested block, winds up being a reference in the outer
+ // block.
+ if (CurBlock)
+ CurBlock->hasBlockDeclRefExprs |= BSI->hasBlockDeclRefExprs;
+
llvm::SmallVector<QualType, 8> ArgTypes;
for (unsigned i = 0, e = BSI->Params.size(); i != e; ++i)
ArgTypes.push_back(BSI->Params[i]->getType());