mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Removes the underscored prefixes from the @_section and @_used attributes, making them public as @section and @used respectively. The SymbolLinkageMarkers experimental feature has been removed as these attributes are now part of the standard language. Implemented expression syntactic checking rules per SE-0492. Major parts: - Renamed @_section to @section and @_used to @used - Removed the SymbolLinkageMarkers experimental feature - Added parsing support for the old underscored names with deprecation warnings - Updated all tests and examples to use the new attribute names - Added syntactic validation for @section to align with SE-0492 (reusing the legality checker by @artemcm) - Changed @DebugDescription macro to explicitly use a tuple type instead of type inferring it, to comply with the expression syntax rules - Added a testcase for the various allowed and disallowed syntactic forms, `test/ConstValues/SectionSyntactic.swift`.
47 lines
2.0 KiB
Swift
47 lines
2.0 KiB
Swift
// RUN: %target-swift-frontend -enable-experimental-feature CompileTimeValuesPreview -parse-as-library -emit-ir %s -o - | %FileCheck %s
|
|
|
|
// REQUIRES: swift_in_compiler
|
|
// REQUIRES: swift_feature_CompileTimeValuesPreview
|
|
|
|
struct MyStruct1<T> {
|
|
var a, b: T
|
|
}
|
|
@section("__TEXT,__mysection") var g_MyStruct1 = MyStruct1<Int>(a: 42, b: 66)
|
|
|
|
struct MyStruct2<T> {
|
|
var a: T
|
|
var b: (T, T)
|
|
}
|
|
@section("__TEXT,__mysection") var g_MyStruct2 = MyStruct2<Int>(a: 42, b: (66, 67))
|
|
|
|
struct MyStruct3<T> {
|
|
var a, b: T
|
|
public init(a: T, b: T) {
|
|
self.a = a
|
|
self.b = b
|
|
}
|
|
}
|
|
@section("__TEXT,__mysection") var g_MyStruct3 = MyStruct3<Int>(a: 42, b: 77)
|
|
|
|
struct MyStruct4<T> {
|
|
var a: T
|
|
var s: MyStruct1<T>
|
|
}
|
|
@section("__TEXT,__mysection") var g_MyStruct4 = MyStruct4<Int>(a: 42, s: MyStruct1<Int>(a: 43, b: 44))
|
|
|
|
struct MyStruct5<T> {
|
|
var q: MyStruct4<T>
|
|
var r: MyStruct4<T>
|
|
public init(q: MyStruct4<T>, r: MyStruct4<T>) {
|
|
self.q = q
|
|
self.r = r
|
|
}
|
|
}
|
|
@section("__TEXT,__mysection") var g_MyStruct5 = MyStruct5<Int>(q: MyStruct4<Int>(a: 42, s: MyStruct1<Int>(a: 43, b: 44)), r: MyStruct4<Int>(a: 42, s: MyStruct1<Int>(a: 43, b: 44)))
|
|
|
|
// CHECK: @"{{.*}}g_MyStruct1{{.*}}Gvp" = hidden global {{.*}} <{ %TSi <{ {{(i32|i64)}} 42 }>, %TSi <{ {{(i32|i64)}} 66 }> }>
|
|
// CHECK: @"{{.*}}g_MyStruct2{{.*}}Gvp" = hidden global {{.*}} <{ %TSi <{ {{(i32|i64)}} 42 }>, <{ %TSi, %TSi }> <{ %TSi <{ {{(i32|i64)}} 66 }>, %TSi <{ {{(i32|i64)}} 67 }> }> }>
|
|
// CHECK: @"{{.*}}g_MyStruct3{{.*}}Gvp" = hidden global {{.*}} <{ %TSi <{ {{(i32|i64)}} 42 }>, %TSi <{ {{(i32|i64)}} 77 }> }>
|
|
// CHECK: @"{{.*}}g_MyStruct4{{.*}}Gvp" = hidden global {{.*}} <{ %TSi <{ {{(i32|i64)}} 42 }>, {{.*}} <{ %TSi <{ {{(i32|i64)}} 43 }>, %TSi <{ {{(i32|i64)}} 44 }> }> }>
|
|
// CHECK: @"{{.*}}g_MyStruct5{{.*}}Gvp" = hidden global {{.*}} <{ {{.*}} <{ %TSi <{ {{(i32|i64)}} 42 }>, {{.*}} <{ %TSi <{ {{(i32|i64)}} 43 }>, %TSi <{ {{(i32|i64)}} 44 }> }> }>, {{.*}} <{ %TSi <{ {{(i32|i64)}} 42 }>, {{.*}} <{ %TSi <{ {{(i32|i64)}} 43 }>, %TSi <{ {{(i32|i64)}} 44 }> }> }> }>
|