diff options
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 2 | ||||
-rw-r--r-- | test/CodeGen/static-forward-decl-fun.c | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index e5bd15e856..43c7129010 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -187,7 +187,7 @@ llvm::Constant *CodeGenModule::GetAddrOfFunctionDecl(const FunctionDecl *D, bool isDefinition) { // See if it is already in the map. If so, just return it. llvm::Constant *&Entry = GlobalDeclMap[D]; - if (Entry) return Entry; + if (!isDefinition && Entry) return Entry; const llvm::Type *Ty = getTypes().ConvertType(D->getType()); diff --git a/test/CodeGen/static-forward-decl-fun.c b/test/CodeGen/static-forward-decl-fun.c new file mode 100644 index 0000000000..636c8fb0d7 --- /dev/null +++ b/test/CodeGen/static-forward-decl-fun.c @@ -0,0 +1,6 @@ +// RUN: clang %s -emit-llvm + +static int staticfun(void); +int (*staticuse1)(void) = staticfun; +static int staticfun() {return 1;} +int (*staticuse2)(void) = staticfun; |