]> granicus.if.org Git - clang/commitdiff
Allow __func__ and __FUNCTION__ and __PRETTY_FUNCTION__ inside blocks.
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 23 Jul 2010 21:53:24 +0000 (21:53 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 23 Jul 2010 21:53:24 +0000 (21:53 +0000)
Radar 8218839.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109272 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/Sema/block-misc.c

index 0d53e2f8beaa240d3a53595850bde657de59e782..8b2e0203b38e2b90bf9075bde7291d908fc09a89 100644 (file)
@@ -1856,6 +1856,8 @@ Sema::OwningExprResult Sema::ActOnPredefinedExpr(SourceLocation Loc,
   // string.
 
   Decl *currentDecl = getCurFunctionOrMethodDecl();
+  if (!currentDecl && getCurBlock())
+    currentDecl = getCurBlock()->TheDecl;
   if (!currentDecl) {
     Diag(Loc, diag::ext_predef_outside_function);
     currentDecl = Context.getTranslationUnitDecl();
index 92be5b1898489176a19bc6d97d0905e507dd5a99..ec74a630045a708d00f7f3d872f3c74570893eba 100644 (file)
@@ -221,3 +221,8 @@ void test21() {
     (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__; };