[cfe-commits] r109272 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/block-misc.c
Fariborz Jahanian
fjahanian at apple.com
Fri Jul 23 14:53:24 PDT 2010
Author: fjahanian
Date: Fri Jul 23 16:53:24 2010
New Revision: 109272
URL: http://llvm.org/viewvc/llvm-project?rev=109272&view=rev
Log:
Allow __func__ and __FUNCTION__ and __PRETTY_FUNCTION__ inside blocks.
Radar 8218839.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/block-misc.c
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=109272&r1=109271&r2=109272&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jul 23 16:53:24 2010
@@ -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();
Modified: cfe/trunk/test/Sema/block-misc.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-misc.c?rev=109272&r1=109271&r2=109272&view=diff
==============================================================================
--- cfe/trunk/test/Sema/block-misc.c (original)
+++ cfe/trunk/test/Sema/block-misc.c Fri Jul 23 16:53:24 2010
@@ -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__; };
More information about the cfe-commits
mailing list