Remaining test a code fixes for @_section->@section rename

This commit is contained in:
Kuba Mracek
2025-10-23 08:43:31 -07:00
parent 2713872bef
commit b47227b57b
4 changed files with 15 additions and 6 deletions

View File

@@ -45,7 +45,7 @@ struct SomeStruct {}
@section("") var g1: Int = 1 // expected-error {{'@section' section name cannot be empty}}
func function() {
@section("__TEXT,__mysection") var l0: Int = 1 // expected-error {{attribute '_section' can only be used in a non-local scope}}
@section("__TEXT,__mysection") var l0: Int = 1 // expected-error {{attribute 'section' can only be used in a non-local scope}}
l0 += 1
_ = l0

View File

@@ -3,13 +3,19 @@
// REQUIRES: swift_in_compiler
// REQUIRES: swift_feature_CompileTimeValuesPreview
// TODO: this should only emit one error per bad compile-time expression, not two
@section("__TEXT,__mysection") var g0: Int = 1
@section("__TEXT,__mysection") var g1: (Int, Int) = (1, 2)
@section("__TEXT,__mysection") var g2: [Int] = [1, 2, 3] // expected-error {{global variable must be a compile-time constant to use @section attribute}}
// expected-error@-1 {{'@const' value should be initialized with a compile-time value}}
@section("__TEXT,__mysection") var g3: [Int:Int] = [:] // expected-error {{global variable must be a compile-time constant to use @section attribute}}
// expected-error@-1 {{'@const' value should be initialized with a compile-time value}}
@section("__TEXT,__mysection") var g4: UInt = 42
@section("__TEXT,__mysection") var g5: String = "hello" // expected-error {{global variable must be a compile-time constant to use @section attribute}}
// expected-error@-1 {{'@const' value should be initialized with a compile-time value}}
@section("__TEXT,__mysection") var g6: Any = 1 // expected-error {{global variable must be a compile-time constant to use @section attribute}}
// expected-error@-1 {{'@const' value should be initialized with a compile-time value}}
@section("__TEXT,__mysection") var g7: UInt8 = 42
@section("__TEXT,__mysection") var g8: Int = 5 * 5
@section("__TEXT,__mysection") var g9 = MemoryLayout<Int>.size
@@ -23,6 +29,7 @@ struct MyStruct1 {
var a: [Int]
}
@section("__TEXT,__mysection") var g_MyStruct1: MyStruct1 = MyStruct1(a: [1, 2, 3]) // expected-error {{global variable must be a compile-time constant to use @section attribute}}
// expected-error@-1 {{'@const' value should be initialized with a compile-time value}}
struct MyStruct2 {
struct SubStruct { var x: Int }
@@ -55,6 +62,7 @@ struct MyStruct4 {
}
}
@section("__TEXT,__mysection") var g_MyStruct4: MyStruct4 = MyStruct4(a: 42) // expected-error {{global variable must be a compile-time constant to use @section attribute}}
// expected-error@-1 {{'@const' value should be initialized with a compile-time value}}
struct MyStruct5 {
struct SubStruct { var x: Int }
@@ -80,6 +88,7 @@ struct MyStruct6 {
}
}
@section("__TEXT,__mysection") var g_MyStruct6: MyStruct6 = MyStruct6(a: 42) // expected-error {{global variable must be a compile-time constant to use @section attribute}}
// expected-error@-1 {{'@const' value should be initialized with a compile-time value}}
@section("__TEXT,__mysection") var gp1: UnsafeMutablePointer<Int>? = nil
@section("__TEXT,__mysection") var gp2: UnsafeMutablePointer<Int>? = UnsafeMutablePointer(bitPattern: 0x42424242)