llvm-project
121 строка · 7.6 Кб
1// RUN: %clang_cc1 -fsyntax-only -verify %s
2
3void function(void) __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration)));
4
5__attribute__((external_source_symbol(language="Swift", defined_in="module")))
6@interface I
7
8- (void)method __attribute__((external_source_symbol(defined_in= "module")));
9
10@end
11
12enum E {
13CaseA __attribute__((external_source_symbol(generated_declaration))),
14CaseB __attribute__((external_source_symbol(generated_declaration, language="Swift")))
15} __attribute__((external_source_symbol(language = "Swift")));
16
17void functionCustomUSR(void) __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration, USR="s:6module17functionCustomUSRyyF")));
18
19void functionCustomUSR2(void) __attribute__((external_source_symbol(language="Swift", defined_in="module", USR="s:6module18functionCustomUSR2yyF", generated_declaration)));
20
21void f2(void)
22__attribute__((external_source_symbol())); // expected-error {{expected 'language', 'defined_in', 'generated_declaration', or 'USR'}}
23void f3(void)
24__attribute__((external_source_symbol(invalid))); // expected-error {{expected 'language', 'defined_in', 'generated_declaration', or 'USR'}}
25void f4(void)
26__attribute__((external_source_symbol(language))); // expected-error {{expected '=' after language}}
27void f5(void)
28__attribute__((external_source_symbol(language=))); // expected-error {{expected string literal for language name in 'external_source_symbol' attribute}}
29void f6(void)
30__attribute__((external_source_symbol(defined_in=20))); // expected-error {{expected string literal for source container name in 'external_source_symbol' attribute}}
31
32void f7(void)
33__attribute__((external_source_symbol(generated_declaration, generated_declaration))); // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
34void f8(void)
35__attribute__((external_source_symbol(language="Swift", language="Swift"))); // expected-error {{duplicate 'language' clause in an 'external_source_symbol' attribute}}
36void f9(void)
37__attribute__((external_source_symbol(defined_in="module", language="Swift", defined_in="foo"))); // expected-error {{duplicate 'defined_in' clause in an 'external_source_symbol' attribute}}
38__attribute__((external_source_symbol(defined_in="module", language="Swift", USR="foo", USR="bar"))); // expected-error {{duplicate 'USR' clause in an 'external_source_symbol' attribute}}
39void f9_1(void);
40
41void f10(void)
42__attribute__((external_source_symbol(generated_declaration, language="Swift", defined_in="foo", generated_declaration, generated_declaration, language="Swift"))); // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
43
44void f11(void)
45__attribute__((external_source_symbol(language="Objective-C++", defined_in="Some file with spaces")));
46
47void f12(void)
48__attribute__((external_source_symbol(language="C Sharp", defined_in="file:////Hello world with spaces. cs")));
49
50void f13(void)
51__attribute__((external_source_symbol(language=Swift))); // expected-error {{expected string literal for language name in 'external_source_symbol' attribute}}
52
53void f14(void)
54__attribute__((external_source_symbol(=))); // expected-error {{expected 'language', 'defined_in', 'generated_declaration', or 'USR'}}
55
56void f15(void)
57__attribute__((external_source_symbol(="Swift"))); // expected-error {{expected 'language', 'defined_in', 'generated_declaration', or 'USR'}}
58
59void f16(void)
60__attribute__((external_source_symbol("Swift", "module", generated_declaration))); // expected-error {{expected 'language', 'defined_in', 'generated_declaration', or 'USR'}}
61
62void f17(void)
63__attribute__((external_source_symbol(language="Swift", "generated_declaration"))); // expected-error {{expected 'language', 'defined_in', 'generated_declaration', or 'USR'}}
64
65void f18(void)
66__attribute__((external_source_symbol(language= =))); // expected-error {{expected string literal for language name in 'external_source_symbol' attribute}}
67
68void f19(void)
69__attribute__((external_source_symbol(defined_in="module" language="swift"))); // expected-error {{expected ')'}} expected-note {{to match this '('}}
70
71void f20(void)
72__attribute__((external_source_symbol(defined_in="module" language="swift" generated_declaration))); // expected-error {{expected ')'}} expected-note {{to match this '('}}
73
74void f21(void)
75__attribute__((external_source_symbol(defined_in= language="swift"))); // expected-error {{expected string literal for source container name in 'external_source_symbol' attribute}}
76
77void f22(void)
78__attribute__((external_source_symbol)); // expected-error {{'external_source_symbol' attribute takes at least 1 argument}}
79
80void f23(void)
81__attribute__((external_source_symbol(defined_in=, language="swift" generated_declaration))); // expected-error {{expected string literal for source container name in 'external_source_symbol' attribute}} expected-error{{expected ')'}} expected-note{{to match this '('}}
82
83void f24(void)
84__attribute__((external_source_symbol(language = generated_declaration))); // expected-error {{expected string literal for language name in 'external_source_symbol' attribute}}
85
86void f25(void)
87__attribute__((external_source_symbol(defined_in=123, defined_in="module"))); // expected-error {{expected string literal for source container name in 'external_source_symbol'}} expected-error {{duplicate 'defined_in' clause in an 'external_source_symbol' attribute}}
88
89void f26(void)
90__attribute__((external_source_symbol(language=Swift, language="Swift", error))); // expected-error {{expected string literal for language name in 'external_source_symbol'}} expected-error {{duplicate 'language' clause in an 'external_source_symbol' attribute}} expected-error {{expected 'language', 'defined_in', 'generated_declaration', or 'USR'}}
91
92void f27(void)
93__attribute__((external_source_symbol(USR=f27))); // expected-error {{expected string literal for USR in 'external_source_symbol' attribute}}
94
95void f28(void)
96__attribute__((external_source_symbol(USR="")));
97
98void f29(void)
99__attribute__((external_source_symbol(language=L"Swift"))); // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect}}
100
101void f30(void)
102__attribute__((external_source_symbol(language="Swift", language=L"Swift"))); // expected-error {{duplicate 'language' clause in an 'external_source_symbol' attribute}} \
103// expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect}}
104
105void f31(void)
106__attribute__((external_source_symbol(USR=u"foo"))); // expected-warning {{encoding prefix 'u' on an unevaluated string literal has no effect}}
107
108void f32(void)
109__attribute__((external_source_symbol(USR="foo", USR=u"foo"))); // expected-error {{duplicate 'USR' clause in an 'external_source_symbol' attribute}} \
110// expected-warning {{encoding prefix 'u' on an unevaluated string literal has no effect}}
111
112void f33(void)
113__attribute__((external_source_symbol(defined_in=U"module"))); // expected-warning {{encoding prefix 'U' on an unevaluated string literal has no effect}}
114
115void f34(void)
116__attribute__((external_source_symbol(defined_in="module", defined_in=U"module"))); // expected-error {{duplicate 'defined_in' clause in an 'external_source_symbol' attribute}} \
117// expected-warning {{encoding prefix 'U' on an unevaluated string literal has no effect}}
118
119#if __has_attribute(external_source_symbol) != 20230206
120# error "invalid __has_attribute version"
121#endif
122