llvm-project/clang/test/SemaObjC/validate-attr-swift_attr.m
Pavel Yaskevich d3daa3c443
[clang/AST] Make it possible to use SwiftAttr in type context (#108631)
Swift ClangImporter now supports concurrency annotations on imported
declarations and their parameters/results, to make it possible to use
imported APIs in Swift safely there has to be a way to annotate
individual parameters and result types with relevant attributes that
indicate that e.g. a block is called on a particular actor or it accepts
a `Sendable` parameter.

To faciliate that `SwiftAttr` is switched from `InheritableAttr` which
is a declaration attribute to `DeclOrTypeAttr`. To support this
attribute in type context we need access to its "Attribute" argument
which requires `AttributedType` to be extended to include `Attr *` when
available instead of just `attr::Kind` otherwise it won't be possible to
determine what attribute should be imported.
2024-10-31 11:15:22 +00:00

16 lines
443 B
Objective-C

// RUN: %clang_cc1 -verify -fsyntax-only %s
// expected-error@+1 {{'swift_attr' attribute takes one argument}}
__attribute__((swift_attr))
@interface I
@end
// expected-error@+1 {{expected string literal as argument of 'swift_attr' attribute}}
__attribute__((swift_attr(1)))
@interface J
@end
@interface Error<T: __attribute__((swift_attr(1))) id>
// expected-error@-1 {{expected string literal as argument of 'swift_attr' attribute}}
@end