Allow __func__ and __FUNCTION__ and __PRETTY_FUNCTION__ inside blocks.
Radar 8218839.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109272 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 0d53e2f..8b2e020 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1856,6 +1856,8 @@
   // string.
 
   Decl *currentDecl = getCurFunctionOrMethodDecl();
+  if (!currentDecl && getCurBlock())
+    currentDecl = getCurBlock()->TheDecl;
   if (!currentDecl) {
     Diag(Loc, diag::ext_predef_outside_function);
     currentDecl = Context.getTranslationUnitDecl();
diff --git a/test/Sema/block-misc.c b/test/Sema/block-misc.c
index 92be5b1..ec74a63 100644
--- a/test/Sema/block-misc.c
+++ b/test/Sema/block-misc.c
@@ -221,3 +221,8 @@
     (void)b[1]; // expected-error {{cannot refer to declaration with an array type inside block}}
   }();
 }
+
+// rdar ://8218839
+const char * (^func)(void) = ^{ return __func__; };
+const char * (^function)(void) = ^{ return __FUNCTION__; };
+const char * (^pretty)(void) = ^{ return __PRETTY_FUNCTION__; };