diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-07-23 21:53:24 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-07-23 21:53:24 +0000 |
commit | eb024acef8a8fef3cb5e01a2e0c3efb90372c8af (patch) | |
tree | 6ac2885ceb8f9b78b499f67119d38b453121049c | |
parent | ab2e020d80afb6d8c88515f6a7e9d371dcc6f2e4 (diff) |
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
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 2 | ||||
-rw-r--r-- | test/Sema/block-misc.c | 5 |
2 files changed, 7 insertions, 0 deletions
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__; }; |