AST: Quote attributes more consistently in DiagnosticsParse.def

This commit is contained in:
Anthony Latsis
2025-04-07 13:43:11 +01:00
parent 5e41794680
commit 7b92a8f041
15 changed files with 61 additions and 60 deletions

View File

@@ -497,7 +497,7 @@ ERROR(expected_precedencegroup_relation,none,
ERROR(expected_sil_keyword,none,
"expected SIL keyword", ())
ERROR(inout_not_attribute, none,
"@inout is no longer an attribute", ())
"'inout' is no longer an attribute", ())
ERROR(only_allowed_in_sil,none,
"'%0' only allowed in SIL modules", (StringRef))
ERROR(expected_sil_type,none,
@@ -520,7 +520,7 @@ ERROR(silfunc_and_silarg_have_incompatible_sil_value_ownership,none,
"Function type specifies: '@%0'. SIL argument specifies: '@%1'.",
(StringRef, StringRef))
ERROR(sil_arg_both_lexical_and_eagerMove,none,
"Function argument is annotated both @_eagerMove and @_noEagerMove, "
"Function argument is annotated both '@_eagerMove' and '@_noEagerMove', "
"but these are incompatible alternatives", ())
ERROR(expected_sil_colon,none,
"expected ':' before %0", (StringRef))
@@ -1624,14 +1624,14 @@ ERROR(attr_availability_duplicate,none,
// originallyDefinedIn
ERROR(originally_defined_in_missing_rparen,none,
"expected ')' in @_originallyDefinedIn argument list", ())
"expected ')' in '@_originallyDefinedIn' argument list", ())
ERROR(originally_defined_in_need_original_module_name,none,
"expected 'module: \"original\"' in the first argument to "
"@_originallyDefinedIn", ())
"'@_originallyDefinedIn'", ())
ERROR(originally_defined_in_need_nonempty_module_name,none,
"original module name cannot be empty in @_originallyDefinedIn", ())
"original module name cannot be empty in '@_originallyDefinedIn'", ())
// backDeploy
ERROR(attr_back_deploy_expected_before_label,none,
@@ -1662,25 +1662,25 @@ ERROR(convention_attribute_witness_method_expected_protocol,none,
// objc
ERROR(attr_objc_missing_colon,none,
"missing ':' after selector piece in @objc attribute", ())
"missing ':' after selector piece in '@objc'", ())
ERROR(attr_objc_expected_rparen,none,
"expected ')' after name for @objc", ())
"expected ')' after name for '@objc'", ())
ERROR(attr_objc_empty_name,none,
"expected name within parentheses of @objc attribute", ())
"expected name within parentheses of '@objc'", ())
ERROR(attr_dynamic_replacement_expected_rparen,none,
"expected ')' after function name for @_dynamicReplacement", ())
"expected ')' after function name for '@_dynamicReplacement'", ())
ERROR(attr_dynamic_replacement_expected_function,none,
"expected a function name in @_dynamicReplacement(for:)", ())
"expected a function name in '@_dynamicReplacement(for:)'", ())
ERROR(attr_dynamic_replacement_expected_for,none,
"expected 'for' in '_dynamicReplacement' attribute", ())
ERROR(attr_dynamic_replacement_expected_colon,none,
"expected ':' after @_dynamicReplacement(for", ())
"expected ':' after '@_dynamicReplacement(for'", ())
ERROR(attr_type_eraser_expected_type_name,none,
"expected a type name in @_typeEraser()", ())
"expected a type name in '@_typeEraser()'", ())
ERROR(attr_type_eraser_expected_rparen,none,
"expected ')' after type name for @_typeEraser", ())
"expected ')' after type name for '@_typeEraser'", ())
ERROR(expected_thrown_error_type,none,
"expected thrown error type after 'throws('", ())
@@ -1698,13 +1698,13 @@ ERROR(attr_isolated_expected_kind,none,
"expected 'any' as the isolation kind", ())
ERROR(attr_private_import_expected_rparen,none,
"expected ')' after function name for @_private", ())
"expected ')' after function name for '@_private'", ())
ERROR(attr_private_import_expected_sourcefile, none,
"expected 'sourceFile' in '_private' attribute", ())
ERROR(attr_private_import_expected_sourcefile_name,none,
"expected a source file name in @_private(sourceFile:)", ())
"expected a source file name in '@_private(sourceFile:)'", ())
ERROR(attr_private_import_expected_colon,none,
"expected ':' after @_private(sourceFile", ())
"expected ':' after '@_private(sourceFile'", ())
// opened
ERROR(opened_attribute_expected_lparen,none,
@@ -1825,18 +1825,18 @@ ERROR(sil_inst_autodiff_expected_differentiability_witness_kind,PointsToFirstBad
"'[vjp]', or '[transpose]'", ())
WARNING(warn_attr_unsafe_removed,none,
"'%0' attribute has been removed in favor of @preconcurrency",
"'%0' attribute has been removed in favor of '@preconcurrency'",
(StringRef))
// _documentation
ERROR(documentation_attr_expected_argument,none,
"@_documentation attribute expected 'visibility' or 'metadata' argument",
"'_documentation' attribute expected 'visibility' or 'metadata' argument",
())
ERROR(documentation_attr_unknown_argument,none,
"unknown argument '%0', expected 'visibility' or 'metadata'",
(StringRef))
ERROR(documentation_attr_expected_access_level,none,
"@_documentation attribute's 'visibility' argument expected an access level",
"'_documentation' attribute's 'visibility' argument expected an access level",
())
ERROR(documentation_attr_unknown_access_level,none,
"unknown visibility '%0', expected an access level keyword",
@@ -1844,26 +1844,26 @@ ERROR(documentation_attr_unknown_access_level,none,
ERROR(documentation_attr_duplicate_visibility,none,
"cannot give more than one visibility to the same item", ())
ERROR(documentation_attr_metadata_expected_text,none,
"@_documentation attribute's 'metadata' argument expected an identifier or "
"'_documentation' attribute's 'metadata' argument expected an identifier or "
"quoted string",
())
ERROR(documentation_attr_duplicate_metadata,none,
"cannot give more than one metadata argument to the same item", ())
ERROR(attr_rawlayout_expected_label,none,
"expected %0 argument to @_rawLayout attribute", (StringRef))
"expected %0 argument to '@_rawLayout'", (StringRef))
ERROR(attr_rawlayout_expected_integer_size,none,
"expected integer literal size in @_rawLayout attribute", ())
"expected integer literal size in '@_rawLayout'", ())
ERROR(attr_rawlayout_expected_integer_alignment,none,
"expected integer literal alignment in @_rawLayout attribute", ())
"expected integer literal alignment in '@_rawLayout'", ())
ERROR(attr_rawlayout_expected_params,none,
"expected %1 argument after %0 argument in @_rawLayout attribute", (StringRef, StringRef))
"expected %1 argument after %0 argument in '@_rawLayout'", (StringRef, StringRef))
ERROR(attr_extern_expected_label,none,
"expected %0 argument to @_extern attribute", (StringRef))
"expected %0 argument to '@_extern'", (StringRef))
ERROR(attr_expected_feature_name,none,
"expected feature name in @%0 attribute", (StringRef))
"expected feature name in '@%0'", (StringRef))
//------------------------------------------------------------------------------
// MARK: Generics parsing diagnostics
@@ -2056,13 +2056,13 @@ ERROR(macro_role_syntax_mismatch,PointsToFirstBadToken,
"%select{a freestanding|an attached}0 macro cannot have the %1 role",
(bool, Identifier))
ERROR(macro_attribute_unknown_label,PointsToFirstBadToken,
"@%select{freestanding|attached}0 has no argument with label %1",
"'@%select{freestanding|attached}0' has no argument with label %1",
(bool, Identifier))
ERROR(macro_attribute_duplicate_label,PointsToFirstBadToken,
"@%select{freestanding|attached}0 already has an argument with "
"'@%select{freestanding|attached}0' already has an argument with "
"label %1", (bool, StringRef))
ERROR(macro_attribute_missing_label,none,
"@%select{freestanding|attached}0 argument is missing label '%1'",
"'@%select{freestanding|attached}0' argument is missing label '%1'",
(bool, StringRef))
ERROR(macro_attribute_unknown_name_kind,PointsToFirstBadToken,
"unknown introduced name kind %0", (Identifier))
@@ -2073,7 +2073,8 @@ ERROR(macro_attribute_introduced_name_requires_argument,PointsToFirstBadToken,
ERROR(macro_attribute_introduced_name_requires_no_argument,PointsToFirstBadToken,
"introduced name kind %0 must not have an argument", (Identifier))
WARNING(macro_expression_attribute_removed,PointsToFirstBadToken,
"@expression has been removed in favor of @freestanding(expression)", ())
"'@expression' has been removed in favor of '@freestanding(expression)'",
())
ERROR(unexpected_attribute_expansion,PointsToFirstBadToken,
"unexpected token '%0' in expanded attribute list",
@@ -2109,16 +2110,16 @@ ERROR(init_accessor_is_not_in_the_primary_declaration,none,
())
ERROR(missing_storage_restrictions_attr_label,none,
"missing label in @storageRestrictions attribute", ())
"missing label in '@storageRestrictions'", ())
ERROR(invalid_storage_restrictions_attr_label,none,
"unexpected label %0 in @storageRestrictions attribute", (Identifier))
"unexpected label %0 in '@storageRestrictions'", (Identifier))
ERROR(duplicate_storage_restrictions_attr_label,none,
"duplicate label %0 in @storageRestrictions attribute", (Identifier))
"duplicate label %0 in '@storageRestrictions'", (Identifier))
ERROR(storage_restrictions_attr_expected_name,none,
"expected property name in @storageRestrictions list", ())
"expected property name in '@storageRestrictions' list", ())
ERROR(requires_experimental_feature, none,
"'%0' %select{attribute|parameter specifier}1 is only valid when experimental feature "

View File

@@ -148,10 +148,10 @@ struct S3: Q, Sendable {
// Historical attribute names do nothing (but are permitted)
// ---------------------------------------------------------------------------
func aFailedExperiment(@_unsafeSendable _ body: @escaping () -> Void) { }
// expected-warning@-1{{'_unsafeSendable' attribute has been removed in favor of @preconcurrency}}
// expected-warning@-1{{'_unsafeSendable' attribute has been removed in favor of '@preconcurrency'}}
func anothingFailedExperiment(@_unsafeMainActor _ body: @escaping () -> Void) { }
// expected-warning@-1{{'_unsafeMainActor' attribute has been removed in favor of @preconcurrency}}
// expected-warning@-1{{'_unsafeMainActor' attribute has been removed in favor of '@preconcurrency'}}
// ---------------------------------------------------------------------------
// Random bugs

View File

@@ -108,10 +108,10 @@ struct S3: Q, Sendable {
// Historical attribute names do nothing (but are permitted)
// ---------------------------------------------------------------------------
func aFailedExperiment(@_unsafeSendable _ body: @escaping () -> Void) { }
// expected-warning@-1{{'_unsafeSendable' attribute has been removed in favor of @preconcurrency}}
// expected-warning@-1{{'_unsafeSendable' attribute has been removed in favor of '@preconcurrency'}}
func anothingFailedExperiment(@_unsafeMainActor _ body: @escaping () -> Void) { }
// expected-warning@-1{{'_unsafeMainActor' attribute has been removed in favor of @preconcurrency}}
// expected-warning@-1{{'_unsafeMainActor' attribute has been removed in favor of '@preconcurrency'}}
// Override matching with @preconcurrency properties.
do {

View File

@@ -19,6 +19,6 @@ macro someMacro() = #externalMacro(module: "", type: "")
macro invalidMacro()
// expected-error@-1 {{macro 'invalidMacro()' requires a definition}}
// expected-error@-2 {{macro 'invalidMacro()' must declare its applicable roles via '@freestanding' or @attached'}}
// expected-error@-2 {{macro 'invalidMacro()' must declare its applicable roles via '@freestanding' or '@attached'}}
#invalidMacro() // expected-error {{no macro named 'invalidMacro'}}

View File

@@ -6,7 +6,7 @@ func escapeByBitCast(f: () -> ()) -> () -> () {
}
func changeFnRep(f: @escaping () -> ()) -> @convention(block) () -> () {
// expected-warning@+1{{'unsafeBitCast' from function type '() -> ()' to '@convention(block) () -> ()' changes @convention and is undefined; use an implicit conversion to change conventions}}
// expected-warning@+1{{'unsafeBitCast' from function type '() -> ()' to '@convention(block) () -> ()' changes '@convention' and is undefined; use an implicit conversion to change conventions}}
return unsafeBitCast(f, to: (@convention(block) () -> ()).self)
}

View File

@@ -2,7 +2,7 @@
// RUN: %target-typecheck-verify-swift -swift-version 5 -module-name Swift -parse-stdlib
// expected-warning@+2{{@expression has been removed in favor of @freestanding(expression)}}
// expected-warning@+2{{'@expression' has been removed in favor of '@freestanding(expression)'}}
// expected-warning@+1{{external macro implementation type 'A.B' could not be found for macro 'myMacro()'}}
@expression macro myMacro() = #externalMacro(module: "A", type: "B")

View File

@@ -6,7 +6,7 @@
@expression macro stringify<T>(_ value: T) -> (T, String) = #externalMacro(module: "MacroDefinition", type: "StringifyMacro")
// expected-note@-1 3{{'stringify' declared here}}
// expected-warning@-2{{external macro implementation type}}
// expected-warning@-3{{@expression has been removed in favor of @freestanding(expression)}}{{1-12=@freestanding(expression)}}
// expected-warning@-3{{'@expression' has been removed in favor of '@freestanding(expression)'}}{{1-12=@freestanding(expression)}}
@freestanding(expression) macro missingMacro1(_: Any) = MissingModule.MissingType // expected-note{{'missingMacro1' declared here}}
// expected-warning@-1{{external macro definitions are now written using #externalMacro}}
// expected-warning@-2{{external macro implementation type}}

View File

@@ -46,7 +46,7 @@ macro am1()
@attached(
accessor,
overloaded, // expected-error{{@attached argument is missing label 'names'}}
overloaded, // expected-error{{'@attached' argument is missing label 'names'}}
unknown, // expected-error{{unknown introduced name kind 'unknown'}}
named, // expected-error{{introduced name kind 'named' requires a single argument '(name)'}}
arbitrary(a) // expected-error{{introduced name kind 'arbitrary' must not have an argument}}

View File

@@ -16,5 +16,5 @@ func test_dynamic_replacement_for2() {
@_dynamicReplacement(for: dynamically_replaceable() // expected-note {{to match this opening '('}}
func test_dynamic_replacement_for3() {
// expected-error@-1 {{expected ')' after function name for @_dynamicReplacement}}
// expected-error@-1 {{expected ')' after function name for '@_dynamicReplacement'}}
}

View File

@@ -4,7 +4,7 @@
@_originallyDefinedIn(module: "foo", OSX 13.13) // expected-error {{'@_originallyDefinedIn' requires that 'foo()' have explicit availability for macOS}}
public func foo() {}
@_originallyDefinedIn(modulename: "foo", OSX 13.13) // expected-error {{expected 'module: "original"' in the first argument to @_originallyDefinedIn}}
@_originallyDefinedIn(modulename: "foo", OSX 13.13) // expected-error {{expected 'module: "original"' in the first argument to '@_originallyDefinedIn'}}
public func foo1() {}
@_originallyDefinedIn(module: "foo", OSX 13.13.3) // expected-warning {{'@_originallyDefinedIn' only uses major and minor version number}}
@@ -14,7 +14,7 @@ public class ToplevelClass {}
@_originallyDefinedIn(module: "foo") // expected-error {{expected at least one platform version in '@_originallyDefinedIn' attribute}}
public class ToplevelClass1 {}
@_originallyDefinedIn(OSX 13.13.3) // expected-error {{expected 'module: "original"' in the first argument to @_originallyDefinedIn}}
@_originallyDefinedIn(OSX 13.13.3) // expected-error {{expected 'module: "original"' in the first argument to '@_originallyDefinedIn'}}
public class ToplevelClass2 {}
@_originallyDefinedIn(module: "foo",

View File

@@ -88,7 +88,7 @@ struct Foo {
var y: Int
var value: (Int, Int) {
@storageRestrictions(initializes: x, y,) // expected-error {{expected property name in @storageRestrictions list}}
@storageRestrictions(initializes: x, y,) // expected-error {{expected property name in '@storageRestrictions' list}}
init(initialValue) {
self.x = initialValue.0
self.y = initialValue.1

View File

@@ -20,12 +20,12 @@ struct SmallVectorBuf<T>: ~Copyable {}
@_rawLayout // expected-error{{expected '('}}
struct NoLayoutSpecified: ~Copyable {}
@_rawLayout() // expected-error{{expected 'size', 'like', or 'likeArrayOf' argument to @_rawLayout attribute}}
@_rawLayout() // expected-error{{expected 'size', 'like', or 'likeArrayOf' argument to '@_rawLayout'}}
struct NoParamsSpecified: ~Copyable {}
@_rawLayout(size: 4) // expected-error{{expected alignment argument after size argument in @_rawLayout attribute}}
@_rawLayout(size: 4) // expected-error{{expected alignment argument after size argument in '@_rawLayout'}}
struct SizeWithoutAlignment: ~Copyable {}
@_rawLayout(likeArrayOf: Optional<Int>) // expected-error{{expected count argument after likeArrayOf argument in @_rawLayout attribute}}
@_rawLayout(likeArrayOf: Optional<Int>) // expected-error{{expected count argument after likeArrayOf argument in '@_rawLayout'}}
struct ArrayWithoutSize: ~Copyable {}

View File

@@ -1999,7 +1999,7 @@ class Class_ObjC2 {
// CHECK-LABEL: @objc(isFoo) func foo() -> Bool {
}
@objc() // expected-error {{expected name within parentheses of @objc attribute}}
@objc() // expected-error {{expected name within parentheses of '@objc'}}
class Class_ObjC3 {
}
@@ -2016,8 +2016,8 @@ extension PlainClass {
// CHECK-LABEL: @objc(createWithRed:green:blue:alpha:) dynamic class func createWith
@objc(createWithRed:green blue:alpha)
class func createWithRed(_: Float, green: Float, blue: Float, alpha: Float) { }
// expected-error@-2{{missing ':' after selector piece in @objc attribute}}{{28-28=:}}
// expected-error@-3{{missing ':' after selector piece in @objc attribute}}{{39-39=:}}
// expected-error@-2{{missing ':' after selector piece in '@objc'}}{{28-28=:}}
// expected-error@-3{{missing ':' after selector piece in '@objc'}}{{39-39=:}}
// CHECK-LABEL: @objc(::) dynamic func badlyNamed
@objc(::) // access-note-move{{PlainClass.badlyNamed(_:y:)}}

View File

@@ -29,11 +29,11 @@ protocol Collection {
@_typeEraser // expected-error {{expected '(' in '_typeEraser' attribute}}
protocol A1 {}
@_typeEraser() // expected-error {{expected a type name in @_typeEraser()}}
@_typeEraser() // expected-error {{expected a type name in '@_typeEraser()'}}
protocol A2 {}
@_typeEraser(AnyP // expected-note {{to match this opening '('}}
protocol A3 {} // expected-error {{expected ')' after type name for @_typeEraser}}
protocol A3 {} // expected-error {{expected ')' after type name for '@_typeEraser'}}
@_typeEraser(AnyP) // expected-error {{@_typeEraser may only be used on 'protocol' declarations}}
func notAProtocol() {}

View File

@@ -604,7 +604,7 @@ func test_invalid_storage_restrictions() {
var a: Int {
@storageRestrictions()
// expected-error@-1 {{missing label in @storageRestrictions attribute}}
// expected-error@-1 {{missing label in '@storageRestrictions'}}
init {}
get { _a }
@@ -612,7 +612,7 @@ func test_invalid_storage_restrictions() {
var b: Int {
@storageRestrictions(initializes:)
// expected-error@-1 {{expected property name in @storageRestrictions list}}
// expected-error@-1 {{expected property name in '@storageRestrictions' list}}
init {}
get { _b }
@@ -620,7 +620,7 @@ func test_invalid_storage_restrictions() {
var c: Int {
@storageRestrictions(initializes: a, initializes: b)
// expected-error@-1 {{duplicate label 'initializes' in @storageRestrictions attribute}}
// expected-error@-1 {{duplicate label 'initializes' in '@storageRestrictions'}}
// expected-error@-2 {{init accessor cannot refer to property 'a'; init accessors can refer only to stored properties}}
init {}
@@ -629,7 +629,7 @@ func test_invalid_storage_restrictions() {
var d: Int {
@storageRestrictions(accesses: a, accesses: c)
// expected-error@-1 {{duplicate label 'accesses' in @storageRestrictions attribute}}
// expected-error@-1 {{duplicate label 'accesses' in '@storageRestrictions'}}
// expected-error@-2 {{init accessor cannot refer to property 'a'; init accessors can refer only to stored properties}}
init {}
@@ -638,7 +638,7 @@ func test_invalid_storage_restrictions() {
var e: Int {
@storageRestrictions(initialize: a, b, accesses: c, d)
// expected-error@-1 {{unexpected label 'initialize' in @storageRestrictions attribute}}
// expected-error@-1 {{unexpected label 'initialize' in '@storageRestrictions'}}
init {}
get { 0 }