From: Fariborz Jahanian Date: Fri, 23 Jul 2010 21:53:24 +0000 (+0000) Subject: Allow __func__ and __FUNCTION__ and __PRETTY_FUNCTION__ inside blocks. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eb024acef8a8fef3cb5e01a2e0c3efb90372c8af;p=clang 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 0d53e2f8be..8b2e0203b3 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -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(); diff --git a/test/Sema/block-misc.c b/test/Sema/block-misc.c index 92be5b1898..ec74a63004 100644 --- a/test/Sema/block-misc.c +++ b/test/Sema/block-misc.c @@ -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__; };