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

@@ -1977,7 +1977,7 @@ StringRef DeclAttribute::getAttrName() const {
case DeclAttrKind::Expose: case DeclAttrKind::Expose:
return "_expose"; return "_expose";
case DeclAttrKind::Section: case DeclAttrKind::Section:
return "_section"; return "section";
case DeclAttrKind::Documentation: case DeclAttrKind::Documentation:
return "_documentation"; return "_documentation";
case DeclAttrKind::Nonisolated: case DeclAttrKind::Nonisolated:

View File

@@ -45,7 +45,7 @@ struct SomeStruct {}
@section("") var g1: Int = 1 // expected-error {{'@section' section name cannot be empty}} @section("") var g1: Int = 1 // expected-error {{'@section' section name cannot be empty}}
func function() { 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 += 1
_ = l0 _ = l0

View File

@@ -3,13 +3,19 @@
// REQUIRES: swift_in_compiler // REQUIRES: swift_in_compiler
// REQUIRES: swift_feature_CompileTimeValuesPreview // 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 g0: Int = 1
@section("__TEXT,__mysection") var g1: (Int, Int) = (1, 2) @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}} @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}} @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 g4: UInt = 42
@section("__TEXT,__mysection") var g5: String = "hello" // expected-error {{global variable must be a compile-time constant to use @section attribute}} @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}} @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 g7: UInt8 = 42
@section("__TEXT,__mysection") var g8: Int = 5 * 5 @section("__TEXT,__mysection") var g8: Int = 5 * 5
@section("__TEXT,__mysection") var g9 = MemoryLayout<Int>.size @section("__TEXT,__mysection") var g9 = MemoryLayout<Int>.size
@@ -23,6 +29,7 @@ struct MyStruct1 {
var a: [Int] 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}} @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 MyStruct2 {
struct SubStruct { var x: Int } 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}} @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 MyStruct5 {
struct SubStruct { var x: Int } 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}} @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 gp1: UnsafeMutablePointer<Int>? = nil
@section("__TEXT,__mysection") var gp2: UnsafeMutablePointer<Int>? = UnsafeMutablePointer(bitPattern: 0x42424242) @section("__TEXT,__mysection") var gp2: UnsafeMutablePointer<Int>? = UnsafeMutablePointer(bitPattern: 0x42424242)

View File

@@ -1592,10 +1592,10 @@ func extern2() {}
@_extern(c) @_extern(wasm, module: "foo", name: "bar") func extern3() @_extern(c) @_extern(wasm, module: "foo", name: "bar") func extern3()
// @used -- banned in @abi // @used -- banned in @abi
@abi(@used func used1()) // expected-error {{unused '_used' attribute in '@abi'}} {{6-12=}} @abi(@used func used1()) // expected-error {{unused 'used' attribute in '@abi'}} {{6-11=}}
@used func used1() {} @used func used1() {}
@abi(@used func used2()) // expected-error {{unused '_used' attribute in '@abi'}} {{6-12=}} @abi(@used func used2()) // expected-error {{unused 'used' attribute in '@abi'}} {{6-11=}}
func used2() {} func used2() {}
@abi(func used3()) @abi(func used3())
@@ -1863,10 +1863,10 @@ func expose2() {}
@_expose(Cxx) func expose3() {} @_expose(Cxx) func expose3() {}
// @section -- banned in @abi // @section -- banned in @abi
@abi(@section("fnord") func section1()) // expected-error {{unused '_section' attribute in '@abi'}} {{6-24=}} @abi(@section("fnord") func section1()) // expected-error {{unused 'section' attribute in '@abi'}} {{6-23=}}
@section("fnord") func section1() {} @section("fnord") func section1() {}
@abi(@section("fnord") func section2()) // expected-error {{unused '_section' attribute in '@abi'}} {{6-24=}} @abi(@section("fnord") func section2()) // expected-error {{unused 'section' attribute in '@abi'}} {{6-23=}}
func section2() {} func section2() {}
@abi(func section3()) @abi(func section3())