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
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index f903e8f..e0d28fa 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -4774,6 +4774,11 @@
   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());