File tree Expand file tree Collapse file tree 4 files changed +11
-4
lines changed Expand file tree Collapse file tree 4 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -700,7 +700,7 @@ Global Variables
700
700
Global variables define regions of memory allocated at compilation time
701
701
instead of run-time.
702
702
703
- Global variable definitions must be initialized.
703
+ Global variable definitions must be initialized with a sized value .
704
704
705
705
Global variables in other translation units can also be declared, in which
706
706
case they don't have an initializer.
Original file line number Diff line number Diff line change @@ -835,6 +835,8 @@ void Verifier::visitGlobalVariable(const GlobalVariable &GV) {
835
835
" Global variable initializer type does not match global "
836
836
" variable type!" ,
837
837
&GV);
838
+ Check (GV.getInitializer ()->getType ()->isSized (),
839
+ " Global variable initializer must be sized" , &GV);
838
840
// If the global has common linkage, it must have a zero initializer and
839
841
// cannot be constant.
840
842
if (GV.hasCommonLinkage ()) {
Original file line number Diff line number Diff line change
1
+ ; RUN: not llvm-as < %s 2>&1 | FileCheck %s
2
+
3
+ @g = global target ("opaque" ) undef
4
+
5
+ ; CHECK: Global variable initializer must be sized
Original file line number Diff line number Diff line change 13
13
14
14
; CHECK-NEXT: Globals cannot contain scalable types
15
15
; CHECK-NEXT: ptr @ScalableVecStructGlobal
16
- @ScalableVecStructGlobal = global { i32 , <vscale x 4 x i32 > } zeroinitializer
16
+ @ScalableVecStructGlobal = external global { i32 , <vscale x 4 x i32 > }
17
17
18
18
; CHECK-NEXT: Globals cannot contain scalable types
19
19
; CHECK-NEXT: ptr @StructTestGlobal
23
23
; CHECK-NEXT: Globals cannot contain scalable types
24
24
; CHECK-NEXT: ptr @StructArrayTestGlobal
25
25
%struct.array.test = type { [2 x <vscale x 1 x double >] }
26
- @StructArrayTestGlobal = global %struct.array.test zeroinitializer
26
+ @StructArrayTestGlobal = external global %struct.array.test
27
27
28
28
; CHECK-NEXT: Globals cannot contain scalable types
29
29
; CHECK-NEXT: ptr @StructTargetTestGlobal
30
30
%struct.target.test = type { target ("aarch64.svcount" ), target ("aarch64.svcount" ) }
31
- @StructTargetTestGlobal = global %struct.target.test zeroinitializer
31
+ @StructTargetTestGlobal = external global %struct.target.test
You can’t perform that action at this time.
0 commit comments