forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathglobal_init_attribute.swift
32 lines (25 loc) · 1007 Bytes
/
global_init_attribute.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// RUN: rm -rf %t
// RUN: mkdir %t
// RUN: %target-swift-frontend -emit-module -o %t %S/Inputs/def_global.swift
// RUN: %target-swift-frontend -parse-as-library -emit-silgen -I %t %s | FileCheck %s
//
// Test that SILGen uses the "global_init" attribute for all global
// variable addressors.
import def_global
let InternalConst = 42
// CHECK-NOT: [global_init]
// CHECK: // global_init_attribute.InternalConst.unsafeMutableAddressor : Swift.Int
// CHECK-NEXT: sil hidden [global_init] @_TF21global_init_attributeau13InternalConstSi
func foo() -> Int {
return ExportedVar
}
func bar(i: Int) {
ExportedVar = i
}
// CHECK-NOT: [global_init]
// CHECK: // def_global.ExportedVar.unsafeMutableAddressor : Swift.Int
// CHECK-NEXT: sil [global_init] @_TF10def_globalau11ExportedVarSi
var InternalFoo = foo()
// CHECK-NOT: [global_init]
// CHECK: // global_init_attribute.InternalFoo.unsafeMutableAddressor : Swift.Int
// CHECK-NEXT: sil hidden [global_init] @_TF21global_init_attributeau11InternalFooSi