Skip to content

Commit 00fc1fa

Browse files
committed
Add an XFAIL-ing test for top-level mode @section globals
1 parent 9d145bc commit 00fc1fa

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Constant globals using @section
2+
// RUN: %target-swift-frontend -emit-ir %s | %FileCheck %s
3+
4+
// TODO
5+
// XFAIL: *
6+
7+
// integer literals
8+
@section("mysection") let intLiteral1 = 42 // ok
9+
@section("mysection") let intLiteral2: Int8 = 127 // ok
10+
@section("mysection") let intLiteral3: Int16 = 32767 // ok
11+
@section("mysection") let intLiteral4: Int32 = 2147483647 // ok
12+
@section("mysection") let intLiteral5: Int64 = 9223372036854775807 // ok
13+
@section("mysection") let intLiteral6: UInt = 42 // ok
14+
@section("mysection") let intLiteral7: UInt8 = 255 // ok
15+
@section("mysection") let intLiteral8: UInt16 = 65535 // ok
16+
@section("mysection") let intLiteral9: UInt32 = 4294967295 // ok
17+
@section("mysection") let intLiteral10: UInt64 = 18446744073709551615 // ok
18+
19+
// floating-point literals
20+
@section("mysection") let floatLiteral1: Float = 3.14 // ok
21+
@section("mysection") let floatLiteral2: Double = 2.718 // ok
22+
23+
// boolean literals
24+
@section("mysection") let boolLiteral1 = true // ok
25+
@section("mysection") let boolLiteral2 = false // ok
26+
27+
func foo() -> Int { return 42 }
28+
func bar(x: Int) -> String { return "test" }
29+
30+
// function references
31+
@section("mysection") let funcRef1 = foo // ok
32+
@section("mysection") let funcRef2 = bar // ok
33+
34+
// metatypes - TODO
35+
//@section("mysection") let metatype1 = Int.self
36+
37+
// tuples
38+
@section("mysection") let tuple1 = (1, 2, 3, 2.718, true) // ok
39+
@section("mysection") let tuple2: (Int, Float, Bool) = (42, 3.14, false) // ok
40+
@section("mysection") let tuple3 = (foo, bar) // ok (function references in tuple)
41+
42+
// CHECK: @"$s9SectionIR11intLiteral1Sivp" = {{.*}}constant %TSi <{ i64 42 }>, section "mysection"
43+
// CHECK: @"$s9SectionIR11intLiteral2s4Int8Vvp" = {{.*}}constant %Ts4Int8V <{ i8 127 }>, section "mysection"
44+
// CHECK: @"$s9SectionIR11intLiteral3s5Int16Vvp" = {{.*}}constant %Ts5Int16V <{ i16 32767 }>, section "mysection"
45+
// CHECK: @"$s9SectionIR11intLiteral4s5Int32Vvp" = {{.*}}constant %Ts5Int32V <{ i32 2147483647 }>, section "mysection"
46+
// CHECK: @"$s9SectionIR11intLiteral5s5Int64Vvp" = {{.*}}constant %Ts5Int64V <{ i64 9223372036854775807 }>, section "mysection"
47+
// CHECK: @"$s9SectionIR11intLiteral6Suvp" = {{.*}}constant %TSu <{ i64 42 }>, section "mysection"
48+
// CHECK: @"$s9SectionIR11intLiteral7s5UInt8Vvp" = {{.*}}constant %Ts5UInt8V <{ i8 -1 }>, section "mysection"
49+
// CHECK: @"$s9SectionIR11intLiteral8s6UInt16Vvp" = {{.*}}constant %Ts6UInt16V <{ i16 -1 }>, section "mysection"
50+
// CHECK: @"$s9SectionIR11intLiteral9s6UInt32Vvp" = {{.*}}constant %Ts6UInt32V <{ i32 -1 }>, section "mysection"
51+
// CHECK: @"$s9SectionIR12intLiteral10s6UInt64Vvp" = {{.*}}constant %Ts6UInt64V <{ i64 -1 }>, section "mysection"
52+
// CHECK: @"$s9SectionIR13floatLiteral1Sfvp" = {{.*}}constant %TSf <{ float 0x40091EB860000000 }>, section "mysection"
53+
// CHECK: @"$s9SectionIR13floatLiteral2Sdvp" = {{.*}}constant %TSd <{ double 2.718000e+00 }>, section "mysection"
54+
// CHECK: @"$s9SectionIR12boolLiteral1Sbvp" = {{.*}}constant %TSb <{ i1 true }>, section "mysection"
55+
// CHECK: @"$s9SectionIR12boolLiteral2Sbvp" = {{.*}}constant %TSb zeroinitializer, section "mysection"
56+
// CHECK: @"$s9SectionIR8funcRef1Siycvp" = {{.*}}constant %swift.function { ptr @"$s9SectionIR3fooSiyF", ptr null }, section "mysection"
57+
// CHECK: @"$s9SectionIR8funcRef2ySSSicvp" = {{.*}}constant %swift.function { ptr @"$s9SectionIR3bar1xSSSi_tF", ptr null }, section "mysection"
58+
// CHECK: @"$s9SectionIR6tuple1Si_S2iSdSbtvp" = {{.*}}constant <{ %TSi, %TSi, %TSi, %TSd, %TSb }> <{ %TSi <{ i64 1 }>, %TSi <{ i64 2 }>, %TSi <{ i64 3 }>, %TSd <{ double 2.718000e+00 }>, %TSb <{ i1 true }> }>, section "mysection"
59+
// CHECK: @"$s9SectionIR6tuple2Si_SfSbtvp" = {{.*}}constant <{ %TSi, %TSf, %TSb }> <{ %TSi <{ i64 42 }>, %TSf <{ float 0x40091EB860000000 }>, %TSb zeroinitializer }>, section "mysection"
60+
// CHECK: @"$s9SectionIR6tuple3Siyc_SSSictvp" = {{.*}}constant <{ %swift.function, %swift.function }> <{ %swift.function { ptr @"$s9SectionIR3fooSiyF", ptr null }, %swift.function { ptr @"$s9SectionIR3bar1xSSSi_tF", ptr null } }>, section "mysection"

0 commit comments

Comments
 (0)