diff options
author | Chris Lattner <sabre@nondot.org> | 2009-04-21 04:41:23 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-04-21 04:41:23 +0000 |
commit | f1c97eb52e55d2d1340a0345ed91e345fddcb65d (patch) | |
tree | 33a50e505ee798692d156ebe65b8dd4140a4c0e3 | |
parent | 5ce24c87918dde1716d6c9f3ca6acf8b6c1c5472 (diff) |
use of predefined identifiers like __func__ at global scope warn in sema,
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
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 2 | ||||
-rw-r--r-- | test/CodeGen/blocks.c | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 906a1e2cd6..3ca625cc72 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -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 diff --git a/test/CodeGen/blocks.c b/test/CodeGen/blocks.c index 4203fce051..c7fe3a91d2 100644 --- a/test/CodeGen/blocks.c +++ b/test/CodeGen/blocks.c @@ -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 |