AST: Quote attributes more consistently in DiagnosticsSema.def

This commit is contained in:
Anthony Latsis
2025-04-07 02:24:50 +01:00
parent 77eb4f05ec
commit 2cd90bdd69
150 changed files with 971 additions and 951 deletions

View File

@@ -68,17 +68,17 @@ func acceptP(_: some P) { }
func testConformance(i: Int) {
// expected-warning@+1{{expression uses unsafe constructs but is not marked with 'unsafe'}}
acceptP(i) // expected-note{{@unsafe conformance of 'Int' to protocol 'P' involves unsafe code}}
acceptP(i) // expected-note{{'@unsafe' conformance of 'Int' to protocol 'P' involves unsafe code}}
}
func returnsOpaqueP() -> some P {
5 // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe'}}
// expected-note@-1{{@unsafe conformance of 'Int' to protocol 'P' involves unsafe code}}
// expected-note@-1{{'@unsafe' conformance of 'Int' to protocol 'P' involves unsafe code}}
}
func returnsExistentialP() -> any P {
5 // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe'}}
// expected-note@-1{{@unsafe conformance of 'Int' to protocol 'P' involves unsafe code}}
// expected-note@-1{{'@unsafe' conformance of 'Int' to protocol 'P' involves unsafe code}}
}
// FIXME: Should work even if the IteratorProtocol conformance is safe
@@ -142,7 +142,7 @@ func casting(value: Any, i: Int) {
_ = unsafe value as! UnsafeType
// expected-warning@+1{{expression uses unsafe constructs but is not marked with 'unsafe'}}
_ = i as any P // expected-note{{@unsafe conformance of 'Int' to protocol 'P' involves unsafe code}}
_ = i as any P // expected-note{{'@unsafe' conformance of 'Int' to protocol 'P' involves unsafe code}}
}
func metatypes() {
@@ -270,7 +270,7 @@ struct UnsafeWrapTest {
}
@safe @unsafe
struct ConfusedStruct { } // expected-error{{struct 'ConfusedStruct' cannot be both @safe and @unsafe}}
struct ConfusedStruct { } // expected-error{{struct 'ConfusedStruct' cannot be both '@safe' and '@unsafe'}}
@unsafe
struct UnsafeContainingUnspecified {

View File

@@ -19,7 +19,7 @@ class C {
func method() { } // expected-note{{overridden declaration is here}}
}
class D1: C { // expected-note{{make class 'D1' @unsafe to allow unsafe overrides of safe superclass methods}}{{1-1=@unsafe }}
class D1: C { // expected-note{{make class 'D1' '@unsafe' to allow unsafe overrides of safe superclass methods}}{{1-1=@unsafe }}
@unsafe
override func method() { } // expected-warning{{override of safe instance method with unsafe instance method}}{{documentation-file=strict-memory-safety}}
}
@@ -143,7 +143,7 @@ struct UnsafeSequence: @unsafe IteratorProtocol, @unsafe Sequence {
func forEachLoop(us: UnsafeSequence) {
for _ in us { } // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe'}}{{documentation-file=strict-memory-safety}}{{12-12=unsafe }}
// expected-note@-1{{@unsafe conformance of 'UnsafeSequence' to protocol 'Sequence' involves unsafe code}}
// expected-note@-1{{'@unsafe' conformance of 'UnsafeSequence' to protocol 'Sequence' involves unsafe code}}
// expected-warning@-2{{for-in loop uses unsafe constructs but is not marked with 'unsafe'}}{{documentation-file=strict-memory-safety}}
for _ in unsafe us { }
// expected-warning@-1{{for-in loop uses unsafe constructs but is not marked with 'unsafe'}}{{documentation-file=strict-memory-safety}}

View File

@@ -73,7 +73,7 @@ class Super {
@unsafe func g() { }
}
class Sub: Super { // expected-note{{make class 'Sub' @unsafe to allow unsafe overrides of safe superclass methods}}{{1-1=@unsafe }}
class Sub: Super { // expected-note{{make class 'Sub' '@unsafe' to allow unsafe overrides of safe superclass methods}}{{1-1=@unsafe }}
@unsafe override func f() { } // expected-warning{{override of safe instance method with unsafe instance method}}{{documentation-file=strict-memory-safety}}
@unsafe override func g() { }
}
@@ -104,9 +104,9 @@ class ExclusivityChecking {
func next() -> Int {
// expected-warning@+1{{expression uses unsafe constructs but is not marked with 'unsafe'}}{{5-5=unsafe }}
value += 1 // expected-note{{reference to @exclusivity(unchecked) property 'value' is unsafe}}
value += 1 // expected-note{{reference to '@exclusivity(unchecked)' property 'value' is unsafe}}
// expected-warning@+1{{expression uses unsafe constructs but is not marked with 'unsafe'}}{{12-12=unsafe }}
return value // expected-note{{reference to @exclusivity(unchecked) property 'value' is unsafe}}
return value // expected-note{{reference to '@exclusivity(unchecked)' property 'value' is unsafe}}
}
}

View File

@@ -6,7 +6,7 @@
// REQUIRES: concurrency
// REQUIRES: swift_feature_StrictConcurrency
@preconcurrency import unsafe_swift_decls // expected-warning{{@preconcurrency import is not memory-safe because it can silently introduce data races}}
@preconcurrency import unsafe_swift_decls // expected-warning{{'@preconcurrency' import is not memory-safe because it can silently introduce data races}}
class C: @unchecked Sendable {
var counter: Int = 0