Allow __func__ and __FUNCTION__ and __PRETTY_FUNCTION__ inside blocks.

Radar 8218839.

llvm-svn: 109272
This commit is contained in:
Fariborz Jahanian 2010-07-23 21:53:24 +00:00
parent ebb84b243b
commit 946274471d
2 changed files with 7 additions and 0 deletions

View 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();

View 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__; };