File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -883,7 +883,8 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
883
883
else if (D->hasAttr <WeakAttr>())
884
884
GV->setLinkage (llvm::GlobalVariable::WeakAnyLinkage);
885
885
else if (!CompileOpts.NoCommon &&
886
- (!D->hasExternalStorage () && !D->getInit ()))
886
+ !D->hasExternalStorage () && !D->getInit () &&
887
+ !D->getAttr <SectionAttr>())
887
888
GV->setLinkage (llvm::GlobalVariable::CommonLinkage);
888
889
else
889
890
GV->setLinkage (llvm::GlobalVariable::ExternalLinkage);
Original file line number Diff line number Diff line change 1
- // RUN: clang-cc -emit-llvm -o - %s | not grep "common"
1
+ // RUN: clang-cc -emit-llvm -o - %s | FileCheck %s
2
2
3
3
// This checks that the global won't be marked as common.
4
4
// (It shouldn't because it's being initialized).
5
5
6
6
int a ;
7
7
int a = 242 ;
8
+ // CHECK: @a = global i32 242
9
+
10
+ // This shouldn't be emitted as common because it has an explicit section.
11
+ // rdar://7119244
12
+ int b __attribute__((section ("foo" )));
13
+
14
+ // CHECK: @b = global i32 0, section "foo"
You can’t perform that action at this time.
0 commit comments