Skip to content

Diagnose invalid swift attributes #84559

@susmonteiro

Description

@susmonteiro

We should emit a diagnostic when swift attributes are not used as intended.
Some examples:

  1. multiple attributes of the same kind should trigger a warning
template<typename T>
struct SWIFT_COPYABLE_IF(T) SWIFT_NONCOPYABLE DoubleAnnotation {};

// We currently ignore SWIFT_COPYABLE_IF quietly, but we should let the user know

template<typename T, typename S>
struct SWIFT_COPYABLE_IF(T) SWIFT_COPYABLE_IF(S) DoubleAnnotation {};

// We currently merge the two attributes, 
// so that DoubleAnnotation is copyable if both T and S are copyable

template<typename T, typename S>
struct SWIFT_NONESCAPABLE SWIFT_NONESCAPABLE DoubleAnnotation {};

// No harm done in the duplicate annotation, but also no reason to do this
  1. in the presence of SWIFT_NONCOPYABLE and SWIFT_COPYABLE_IF, or SWIFT_NONESCAPABLE and SWIFT_ESCAPABLE_IF, we give precedence to the first attribute and thus never parse the second one. If the second attribute contains garbage, we should emit a diagnostic even if this attribute is ignored
template<typename T>
struct SWIFT_COPYABLE_IF(garbage) SWIFT_NONCOPYABLE InvalidAnnotation {};

// "garbage" is invalid, but we don't get a diagnostic

Metadata

Metadata

Assignees

Labels

c++ interopFeature: Interoperability with C++

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions