aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/CodeGenModule.cpp2
-rw-r--r--test/CodeGen/global-init.c7
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index f0aa8b7d14..80ef53f5f9 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -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:
diff --git a/test/CodeGen/global-init.c b/test/CodeGen/global-init.c
new file mode 100644
index 0000000000..133a3b5373
--- /dev/null
+++ b/test/CodeGen/global-init.c
@@ -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;