| 1 |
// RUN: %clang_cc1 -verify -fsyntax-only -fobjc-arc -fblocks %s |
| 2 |
|
| 3 |
#define SWIFT_NAME(name) __attribute__((swift_name(name))) |
| 4 |
#define SWIFT_ASYNC_NAME(name) __attribute__((__swift_async_name__(name))) |
| 5 |
|
| 6 |
namespace MyNS { |
| 7 |
struct NestedStruct {}; |
| 8 |
} |
| 9 |
|
| 10 |
void nestedStruct_method(MyNS::NestedStruct) SWIFT_NAME("MyNS.NestedStruct.method(self:)"); |
| 11 |
void nestedStruct_methodConstRef(const MyNS::NestedStruct&) SWIFT_NAME("MyNS.NestedStruct.methodConstRef(self:)"); |
| 12 |
void nestedStruct_invalidContext1(MyNS::NestedStruct) SWIFT_NAME(".MyNS.NestedStruct.invalidContext1(self:)"); // expected-warning {{'swift_name' attribute has invalid identifier for the context name}} |
| 13 |
void nestedStruct_invalidContext2(MyNS::NestedStruct) SWIFT_NAME("MyNS::NestedStruct.invalidContext2(self:)"); // expected-warning {{'swift_name' attribute has invalid identifier for the context name}} |
| 14 |
void nestedStruct_invalidContext3(MyNS::NestedStruct) SWIFT_NAME("::MyNS::NestedStruct.invalidContext3(self:)"); // expected-warning {{'swift_name' attribute has invalid identifier for the context name}} |
| 15 |
void nestedStruct_invalidContext4(MyNS::NestedStruct) SWIFT_NAME("MyNS..NestedStruct.invalidContext4(self:)"); // expected-warning {{'swift_name' attribute has invalid identifier for the context name}} |
| 16 |
void nestedStruct_invalidContext5(MyNS::NestedStruct) SWIFT_NAME("MyNS.NestedStruct.invalidContext5.(self:)"); // expected-warning {{'swift_name' attribute has invalid identifier for the base name}} |
| 17 |
void nestedStruct_invalidContext6(MyNS::NestedStruct) SWIFT_NAME("MyNS.NestedStruct::invalidContext6(self:)"); // expected-warning {{'swift_name' attribute has invalid identifier for the base name}} |
| 18 |
|
| 19 |
namespace MyNS { |
| 20 |
namespace MyDeepNS { |
| 21 |
struct DeepNestedStruct {}; |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
void deepNestedStruct_method(MyNS::MyDeepNS::DeepNestedStruct) SWIFT_NAME("MyNS.MyDeepNS.DeepNestedStruct.method(self:)"); |
| 26 |
void deepNestedStruct_methodConstRef(const MyNS::MyDeepNS::DeepNestedStruct&) SWIFT_NAME("MyNS.MyDeepNS.DeepNestedStruct.methodConstRef(self:)"); |
| 27 |
void deepNestedStruct_invalidContext(const MyNS::MyDeepNS::DeepNestedStruct&) SWIFT_NAME("MyNS::MyDeepNS::DeepNestedStruct.methodConstRef(self:)"); // expected-warning {{'swift_name' attribute has invalid identifier for the context name}} |
| 28 |
|
| 29 |
typedef MyNS::MyDeepNS::DeepNestedStruct DeepNestedStructTypedef; |
| 30 |
|
| 31 |
void deepNestedStructTypedef_method(DeepNestedStructTypedef) SWIFT_NAME("DeepNestedStructTypedef.method(self:)"); |
| 32 |
void deepNestedStructTypedef_methodQualName(MyNS::MyDeepNS::DeepNestedStruct) SWIFT_NAME("DeepNestedStructTypedef.method(self:)"); |
| 33 |
|
| 34 |
struct TopLevelStruct { |
| 35 |
struct StructInStruct {}; |
| 36 |
}; |
| 37 |
|
| 38 |
void structInStruct_method(TopLevelStruct::StructInStruct) SWIFT_NAME("TopLevelStruct.StructInStruct.method(self:)"); |
| 39 |
void structInStruct_invalidContext(TopLevelStruct::StructInStruct) SWIFT_NAME("TopLevelStruct::StructInStruct.method(self:)"); // expected-warning {{'swift_name' attribute has invalid identifier for the context name}} |
| 40 |
|
| 41 |
typedef int (^CallbackTy)(void); |
| 42 |
|
| 43 |
class CXXClass { |
| 44 |
public: |
| 45 |
virtual void doSomethingWithCallback(CallbackTy callback) SWIFT_ASYNC_NAME("doSomething()"); |
| 46 |
|
| 47 |
// expected-warning@+1 {{too few parameters in the signature specified by the '__swift_async_name__' attribute (expected 1; got 0)}} |
| 48 |
virtual void doSomethingWithCallback(int x, CallbackTy callback) SWIFT_ASYNC_NAME("doSomething()"); |
| 49 |
}; |