If a global var decl has an initializer, make sure to always set its linkage to external.

llvm-svn: 60462
This commit is contained in:
Anders Carlsson 2008-12-03 05:51:23 +00:00
parent cc78cdf275
commit 6a113d9ddb
2 changed files with 9 additions and 0 deletions

View File

@ -607,6 +607,8 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
case VarDecl::None:
if (!D->getInit())
GV->setLinkage(llvm::GlobalVariable::CommonLinkage);
else
GV->setLinkage(llvm::GlobalVariable::ExternalLinkage);
break;
case VarDecl::Extern:
case VarDecl::PrivateExtern:

View File

@ -0,0 +1,7 @@
// RUN: clang -emit-llvm -o - %s | not grep "common"
// This checks that the global won't be marked as common.
// (It shouldn't because it's being initialized).
int a;
int a = 242;