]> granicus.if.org Git - clang/commitdiff
use of predefined identifiers like __func__ at global scope warn in sema,
authorChris Lattner <sabre@nondot.org>
Tue, 21 Apr 2009 04:41:23 +0000 (04:41 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 21 Apr 2009 04:41:23 +0000 (04:41 +0000)
but crashed codegen.  Fix this to report the name of the llvm function.
This fixes rdar://6808051

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

lib/CodeGen/CGExpr.cpp
test/CodeGen/blocks.c

index 906a1e2cd6cbfa79ee860186094f37fc6e99fd5f..3ca625cc726b64c059a5451e74f042a0e1a4b0fb 100644 (file)
@@ -753,7 +753,7 @@ LValue CodeGenFunction::EmitPredefinedFunctionName(unsigned Type) {
   }
 
   std::string FunctionName;
-  if(const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurFuncDecl)) {
+  if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(CurFuncDecl)) {
     FunctionName = CGM.getMangledName(FD);
   } else {
     // Just get the mangled name; skipping the asm prefix if it
index 4203fce051deba44f343ea7f01de1ed3ce572783..c7fe3a91d25bf0cf6bb67aff90f9980c6e1bbcaf 100644 (file)
@@ -17,4 +17,10 @@ struct s0 f2(struct s0 a0) {
   return ^(struct s0 a1){ return a1; }(a0);
 }
 
+// This should not crash: rdar://6808051
+void *P = ^{
+  void *Q = __func__;
+};
+
+
 // RUN: true