Skip to content

Commit b47227b

Browse files
committed
Remaining test a code fixes for @_section->@section rename
1 parent 2713872 commit b47227b

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

lib/AST/Attr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1977,7 +1977,7 @@ StringRef DeclAttribute::getAttrName() const {
19771977
case DeclAttrKind::Expose:
19781978
return "_expose";
19791979
case DeclAttrKind::Section:
1980-
return "_section";
1980+
return "section";
19811981
case DeclAttrKind::Documentation:
19821982
return "_documentation";
19831983
case DeclAttrKind::Nonisolated:

test/IRGen/section_errors.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct SomeStruct {}
4545
@section("") var g1: Int = 1 // expected-error {{'@section' section name cannot be empty}}
4646

4747
func function() {
48-
@section("__TEXT,__mysection") var l0: Int = 1 // expected-error {{attribute '_section' can only be used in a non-local scope}}
48+
@section("__TEXT,__mysection") var l0: Int = 1 // expected-error {{attribute 'section' can only be used in a non-local scope}}
4949
l0 += 1
5050
_ = l0
5151

test/IRGen/section_non_const.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@
33
// REQUIRES: swift_in_compiler
44
// REQUIRES: swift_feature_CompileTimeValuesPreview
55

6+
// TODO: this should only emit one error per bad compile-time expression, not two
7+
68
@section("__TEXT,__mysection") var g0: Int = 1
79
@section("__TEXT,__mysection") var g1: (Int, Int) = (1, 2)
810
@section("__TEXT,__mysection") var g2: [Int] = [1, 2, 3] // expected-error {{global variable must be a compile-time constant to use @section attribute}}
11+
// expected-error@-1 {{'@const' value should be initialized with a compile-time value}}
912
@section("__TEXT,__mysection") var g3: [Int:Int] = [:] // expected-error {{global variable must be a compile-time constant to use @section attribute}}
13+
// expected-error@-1 {{'@const' value should be initialized with a compile-time value}}
1014
@section("__TEXT,__mysection") var g4: UInt = 42
1115
@section("__TEXT,__mysection") var g5: String = "hello" // expected-error {{global variable must be a compile-time constant to use @section attribute}}
16+
// expected-error@-1 {{'@const' value should be initialized with a compile-time value}}
1217
@section("__TEXT,__mysection") var g6: Any = 1 // expected-error {{global variable must be a compile-time constant to use @section attribute}}
18+
// expected-error@-1 {{'@const' value should be initialized with a compile-time value}}
1319
@section("__TEXT,__mysection") var g7: UInt8 = 42
1420
@section("__TEXT,__mysection") var g8: Int = 5 * 5
1521
@section("__TEXT,__mysection") var g9 = MemoryLayout<Int>.size
@@ -23,6 +29,7 @@ struct MyStruct1 {
2329
var a: [Int]
2430
}
2531
@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}}
32+
// expected-error@-1 {{'@const' value should be initialized with a compile-time value}}
2633

2734
struct MyStruct2 {
2835
struct SubStruct { var x: Int }
@@ -55,6 +62,7 @@ struct MyStruct4 {
5562
}
5663
}
5764
@section("__TEXT,__mysection") var g_MyStruct4: MyStruct4 = MyStruct4(a: 42) // expected-error {{global variable must be a compile-time constant to use @section attribute}}
65+
// expected-error@-1 {{'@const' value should be initialized with a compile-time value}}
5866

5967
struct MyStruct5 {
6068
struct SubStruct { var x: Int }
@@ -80,6 +88,7 @@ struct MyStruct6 {
8088
}
8189
}
8290
@section("__TEXT,__mysection") var g_MyStruct6: MyStruct6 = MyStruct6(a: 42) // expected-error {{global variable must be a compile-time constant to use @section attribute}}
91+
// expected-error@-1 {{'@const' value should be initialized with a compile-time value}}
8392

8493
@section("__TEXT,__mysection") var gp1: UnsafeMutablePointer<Int>? = nil
8594
@section("__TEXT,__mysection") var gp2: UnsafeMutablePointer<Int>? = UnsafeMutablePointer(bitPattern: 0x42424242)

test/attr/attr_abi.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,10 +1592,10 @@ func extern2() {}
15921592
@_extern(c) @_extern(wasm, module: "foo", name: "bar") func extern3()
15931593

15941594
// @used -- banned in @abi
1595-
@abi(@used func used1()) // expected-error {{unused '_used' attribute in '@abi'}} {{6-12=}}
1595+
@abi(@used func used1()) // expected-error {{unused 'used' attribute in '@abi'}} {{6-11=}}
15961596
@used func used1() {}
15971597

1598-
@abi(@used func used2()) // expected-error {{unused '_used' attribute in '@abi'}} {{6-12=}}
1598+
@abi(@used func used2()) // expected-error {{unused 'used' attribute in '@abi'}} {{6-11=}}
15991599
func used2() {}
16001600

16011601
@abi(func used3())
@@ -1863,10 +1863,10 @@ func expose2() {}
18631863
@_expose(Cxx) func expose3() {}
18641864

18651865
// @section -- banned in @abi
1866-
@abi(@section("fnord") func section1()) // expected-error {{unused '_section' attribute in '@abi'}} {{6-24=}}
1866+
@abi(@section("fnord") func section1()) // expected-error {{unused 'section' attribute in '@abi'}} {{6-23=}}
18671867
@section("fnord") func section1() {}
18681868

1869-
@abi(@section("fnord") func section2()) // expected-error {{unused '_section' attribute in '@abi'}} {{6-24=}}
1869+
@abi(@section("fnord") func section2()) // expected-error {{unused 'section' attribute in '@abi'}} {{6-23=}}
18701870
func section2() {}
18711871

18721872
@abi(func section3())

0 commit comments

Comments
 (0)