Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions include/swift/AST/DiagnosticGroups.def
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@

GROUP(no_group, "")

GROUP(DeprecatedDeclaration, "DeprecatedDeclaration.md")
GROUP(Unsafe, "Unsafe.md")
GROUP(UnknownWarningGroup, "UnknownWarningGroup.md")
GROUP(PreconcurrencyImport, "PreconcurrencyImport.md")
GROUP(StrictLanguageFeatures, "StrictLanguageFeatures.md")
GROUP(ExistentialAny, "ExistentialAny.md")
GROUP(DeprecatedDeclaration, "deprecated-declaration.md")
GROUP(StrictMemorySafety, "strict-memory-safety.md")
GROUP(UnknownWarningGroup, "unknown-warning-group.md")
GROUP(PreconcurrencyImport, "preconcurrency-import.md")
GROUP(StrictLanguageFeatures, "strict-language-features.md")
GROUP(ExistentialAny, "existential-any.md")

#define UNDEFINE_DIAGNOSTIC_GROUPS_MACROS
#include "swift/AST/DefineDiagnosticGroupsMacros.h"
2 changes: 1 addition & 1 deletion include/swift/AST/DiagnosticsFrontend.def
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ ERROR(experimental_not_supported_in_production,none,
"experimental feature '%0' cannot be enabled in production compiler",
(StringRef))

GROUPED_WARNING(command_line_conflicts_with_strict_safety,Unsafe,none,
GROUPED_WARNING(command_line_conflicts_with_strict_safety,StrictMemorySafety,none,
"'%0' is not memory-safe and should not be combined with "
"strict memory safety checking", (StringRef))

Expand Down
14 changes: 7 additions & 7 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -8196,7 +8196,7 @@ NOTE(note_use_of_unsafe_conformance_is_unsafe,none,
NOTE(note_unsafe_storage,none,
"%kindbase1 involves unsafe type %2", (bool, const ValueDecl *, Type))

GROUPED_WARNING(decl_unsafe_storage,Unsafe,none,
GROUPED_WARNING(decl_unsafe_storage,StrictMemorySafety,none,
"%kindbase0 has storage involving unsafe types",
(const Decl *))
NOTE(decl_storage_mark_unsafe,none,
Expand All @@ -8206,11 +8206,11 @@ NOTE(decl_storage_mark_safe,none,
"add '@safe' if this type encapsulates the unsafe storage in "
"a safe interface", ())

GROUPED_WARNING(unsafe_superclass,Unsafe,none,
GROUPED_WARNING(unsafe_superclass,StrictMemorySafety,none,
"%kindbase0 has superclass involving unsafe type %1",
(const ValueDecl *, Type))

GROUPED_WARNING(conformance_involves_unsafe,Unsafe,none,
GROUPED_WARNING(conformance_involves_unsafe,StrictMemorySafety,none,
"conformance of %0 to %kind1 involves unsafe code; use '@unsafe' to "
"indicate that the conformance is not memory-safe",
(Type, const ValueDecl *))
Expand All @@ -8221,15 +8221,15 @@ NOTE(note_type_witness_unsafe,none,
"unsafe type %0 cannot satisfy safe associated type %1",
(Type, DeclName))

GROUPED_WARNING(override_safe_with_unsafe,Unsafe,none,
GROUPED_WARNING(override_safe_with_unsafe,StrictMemorySafety,none,
"override of safe %0 with unsafe %0", (DescriptiveDeclKind))

GROUPED_WARNING(preconcurrency_import_unsafe,Unsafe,none,
GROUPED_WARNING(preconcurrency_import_unsafe,StrictMemorySafety,none,
"@preconcurrency import is not memory-safe because it can silently "
"introduce data races", ())
GROUPED_WARNING(unsafe_without_unsafe,Unsafe,none,
GROUPED_WARNING(unsafe_without_unsafe,StrictMemorySafety,none,
"expression uses unsafe constructs but is not marked with 'unsafe'", ())
GROUPED_WARNING(for_unsafe_without_unsafe,Unsafe,none,
GROUPED_WARNING(for_unsafe_without_unsafe,StrictMemorySafety,none,
"for-in loop uses unsafe constructs but is not marked with 'unsafe'", ())
WARNING(no_unsafe_in_unsafe,none,
"no unsafe operations occur within 'unsafe' expression", ())
Expand Down
4 changes: 2 additions & 2 deletions test/Unsafe/safe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ func testUnsafeAsSequenceForEach() {

// expected-warning@+1{{expression uses unsafe constructs but is not marked with 'unsafe'}}{{12-12=unsafe }}
for _ in uas { } // expected-note{{conformance}}
// expected-warning@-1{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}{{7-7=unsafe }}
// expected-warning@-1{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}{{7-7=unsafe }}

for _ in unsafe uas { } // expected-warning{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}{{7-7=unsafe }}
for _ in unsafe uas { } // expected-warning{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}{{7-7=unsafe }}

for unsafe _ in unsafe uas { } // okay
}
Expand Down
2 changes: 1 addition & 1 deletion test/Unsafe/safe_argument_suppression.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class NotSafeSubclass: NotSafe {
_ = NotSafe[ns]
NotSafe.doStatically(NotSafe.self)

ns.stillUnsafe() // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}
ns.stillUnsafe() // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}
// expected-note@-1{{reference to parameter 'ns' involves unsafe type 'NotSafe'}}
// expected-note@-2{{reference to unsafe instance method 'stillUnsafe()'}}
}
Expand Down
16 changes: 8 additions & 8 deletions test/Unsafe/unsafe-suppression.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class C {

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 [Unsafe]}}
override func method() { } // expected-warning{{override of safe instance method with unsafe instance method [StrictMemorySafety]}}
}

@unsafe class D2: C {
Expand All @@ -34,7 +34,7 @@ protocol P {
}

struct S1: P {
// expected-warning@-1{{conformance of 'S1' to protocol 'P' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [Unsafe]}}{{12-12=@unsafe }}
// expected-warning@-1{{conformance of 'S1' to protocol 'P' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [StrictMemorySafety]}}{{12-12=@unsafe }}
@unsafe
func protoMethod() { } // expected-note{{unsafe instance method 'protoMethod()' cannot satisfy safe requirement}}
}
Expand All @@ -48,7 +48,7 @@ struct S2: P {
struct S3 { }

extension S3: P {
// expected-warning@-1{{conformance of 'S3' to protocol 'P' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [Unsafe]}}{{15-15=@unsafe }}
// expected-warning@-1{{conformance of 'S3' to protocol 'P' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [StrictMemorySafety]}}{{15-15=@unsafe }}
@unsafe
func protoMethod() { } // expected-note{{unsafe instance method 'protoMethod()' cannot satisfy safe requirement}}
}
Expand Down Expand Up @@ -116,12 +116,12 @@ extension UnsafeOuter {
var yieldUnsafe: Int {
_read {
@unsafe let x = 5
yield x // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}
yield x // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}
// expected-note@-1{{reference to unsafe let 'x'}}
}
_modify {
@unsafe var x = 5
yield &x // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}
yield &x // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}
// expected-note@-1{{reference to unsafe var 'x'}}
}
}
Expand All @@ -142,9 +142,9 @@ 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' [Unsafe]}}{{12-12=unsafe }}
for _ in us { } // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}{{12-12=unsafe }}
// 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' [Unsafe]}}
// expected-warning@-2{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}
for _ in unsafe us { }
// expected-warning@-1{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}
// expected-warning@-1{{for-in loop uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}
}
18 changes: 9 additions & 9 deletions test/Unsafe/unsafe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protocol P {
@unsafe func g()
}

struct XP: P { // expected-warning{{conformance of 'XP' to protocol 'P' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [Unsafe]}}{{12-12=@unsafe }}
struct XP: P { // expected-warning{{conformance of 'XP' to protocol 'P' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [StrictMemorySafety]}}{{12-12=@unsafe }}
@unsafe func f() { } // expected-note{{unsafe instance method 'f()' cannot satisfy safe requirement}}
@unsafe func g() { }
}
Expand All @@ -30,7 +30,7 @@ protocol Ptrable2 {
}

extension HasAPointerType: Ptrable2 { } // expected-note{{unsafe type 'HasAPointerType.Ptr' (aka 'PointerType') cannot satisfy safe associated type 'Ptr'}}
// expected-warning@-1{{conformance of 'HasAPointerType' to protocol 'Ptrable2' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [Unsafe]}}{{28-28=@unsafe }}
// expected-warning@-1{{conformance of 'HasAPointerType' to protocol 'Ptrable2' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [StrictMemorySafety]}}{{28-28=@unsafe }}

struct UnsafeXP: @unsafe P {
@unsafe func f() { }
Expand All @@ -44,7 +44,7 @@ protocol MultiP {

struct ConformsToMultiP { }

// expected-warning@+1{{conformance of 'ConformsToMultiP' to protocol 'MultiP' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [Unsafe]}}{{29-29=@unsafe }}
// expected-warning@+1{{conformance of 'ConformsToMultiP' to protocol 'MultiP' involves unsafe code; use '@unsafe' to indicate that the conformance is not memory-safe [StrictMemorySafety]}}{{29-29=@unsafe }}
extension ConformsToMultiP: MultiP {
// expected-note@-1{{unsafe type 'UnsafeSuper' cannot satisfy safe associated type 'Ptr'}}
@unsafe func f() -> UnsafeSuper {
Expand Down Expand Up @@ -74,7 +74,7 @@ class Super {
}

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 [Unsafe]}}
@unsafe override func f() { } // expected-warning{{override of safe instance method with unsafe instance method [StrictMemorySafety]}}
@unsafe override func g() { }
}

Expand Down Expand Up @@ -117,7 +117,7 @@ class ExclusivityChecking {
func f() { }
};

// expected-warning@+1{{class 'UnsafeSub' has superclass involving unsafe type 'UnsafeSuper' [Unsafe]}}{{1-1=@unsafe }}
// expected-warning@+1{{class 'UnsafeSub' has superclass involving unsafe type 'UnsafeSuper' [StrictMemorySafety]}}{{1-1=@unsafe }}
class UnsafeSub: UnsafeSuper { }

// -----------------------------------------------------------------------
Expand All @@ -129,13 +129,13 @@ struct BufferThingy<T> {
}

func testConstruction() {
let _ = BufferThingy<Int>(count: 17) // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}{{11-11=unsafe }}
let _ = BufferThingy<Int>(count: 17) // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}{{11-11=unsafe }}
// expected-note@-1{{reference to unsafe initializer 'init(count:)'}}
}

func testRHS(b: Bool, x: Int) {
@unsafe let limit = 17
if b && x > limit { // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [Unsafe]}}{{6-6=unsafe }}
if b && x > limit { // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}{{6-6=unsafe }}
// expected-note@-1{{reference to unsafe let 'limit'}}
}
}
Expand Down Expand Up @@ -171,7 +171,7 @@ typealias SuperUnsafe = UnsafeSuper

@unsafe typealias SuperUnsafe2 = UnsafeSuper

// expected-warning@+3{{enum 'HasUnsafeThings' has storage involving unsafe types [Unsafe]}}
// expected-warning@+3{{enum 'HasUnsafeThings' has storage involving unsafe types [StrictMemorySafety]}}
// expected-note@+2{{add '@unsafe' if this type is also unsafe to use}}{{1-1=@unsafe }}
// expected-note@+1{{add '@safe' if this type encapsulates the unsafe storage in a safe interface}}{{1-1=@safe }}
enum HasUnsafeThings {
Expand All @@ -181,7 +181,7 @@ case one(UnsafeSuper) // expected-note{{enum case 'one' involves unsafe type 'Un
case two(UnsafeSuper) // expected-note{{enum case 'two' involves unsafe type 'UnsafeSuper'}}
}

// expected-warning@+3{{class 'ClassWithUnsafeStorage' has storage involving unsafe types [Unsafe]}}
// expected-warning@+3{{class 'ClassWithUnsafeStorage' has storage involving unsafe types [StrictMemorySafety]}}
// expected-note@+2{{add '@unsafe' if this type is also unsafe to use}}{{1-1=@unsafe }}
// expected-note@+1{{add '@safe' if this type encapsulates the unsafe storage in a safe interface}}{{1-1=@safe }}
class ClassWithUnsafeStorage {
Expand Down