Debian Codegraph @

clang/test/Parser/attr-external-source-symbol.m

raw
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2
3 void 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
12 enum E {
13 CaseA __attribute__((external_source_symbol(generated_declaration))),
14 CaseB __attribute__((external_source_symbol(generated_declaration, language="Swift")))
15 } __attribute__((external_source_symbol(language = "Swift")));
16
17 void functionCustomUSR(void) __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration, USR="s:6module17functionCustomUSRyyF")));
18
19 void functionCustomUSR2(void) __attribute__((external_source_symbol(language="Swift", defined_in="module", USR="s:6module18functionCustomUSR2yyF", generated_declaration)));
20
21 void f2(void)
22 __attribute__((external_source_symbol())); // expected-error {{expected 'language', 'defined_in', 'generated_declaration', or 'USR'}}
23 void f3(void)
24 __attribute__((external_source_symbol(invalid))); // expected-error {{expected 'language', 'defined_in', 'generated_declaration', or 'USR'}}
25 void f4(void)
26 __attribute__((external_source_symbol(language))); // expected-error {{expected '=' after language}}
27 void f5(void)
28 __attribute__((external_source_symbol(language=))); // expected-error {{expected string literal for language name in 'external_source_symbol' attribute}}
29 void 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
32 void f7(void)
33 __attribute__((external_source_symbol(generated_declaration, generated_declaration))); // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
34 void f8(void)
35 __attribute__((external_source_symbol(language="Swift", language="Swift"))); // expected-error {{duplicate 'language' clause in an 'external_source_symbol' attribute}}
36 void 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}}
39 void f9_1(void);
40
41 void 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
44 void f11(void)
45 __attribute__((external_source_symbol(language="Objective-C++", defined_in="Some file with spaces")));
46
47 void f12(void)
48 __attribute__((external_source_symbol(language="C Sharp", defined_in="file:////Hello world with spaces. cs")));
49
50 void f13(void)
51 __attribute__((external_source_symbol(language=Swift))); // expected-error {{expected string literal for language name in 'external_source_symbol' attribute}}
52
53 void f14(void)
54 __attribute__((external_source_symbol(=))); // expected-error {{expected 'language', 'defined_in', 'generated_declaration', or 'USR'}}
55
56 void f15(void)
57 __attribute__((external_source_symbol(="Swift"))); // expected-error {{expected 'language', 'defined_in', 'generated_declaration', or 'USR'}}
58
59 void f16(void)
60 __attribute__((external_source_symbol("Swift", "module", generated_declaration))); // expected-error {{expected 'language', 'defined_in', 'generated_declaration', or 'USR'}}
61
62 void f17(void)
63 __attribute__((external_source_symbol(language="Swift", "generated_declaration"))); // expected-error {{expected 'language', 'defined_in', 'generated_declaration', or 'USR'}}
64
65 void f18(void)
66 __attribute__((external_source_symbol(language= =))); // expected-error {{expected string literal for language name in 'external_source_symbol' attribute}}
67
68 void f19(void)
69 __attribute__((external_source_symbol(defined_in="module" language="swift"))); // expected-error {{expected ')'}} expected-note {{to match this '('}}
70
71 void f20(void)
72 __attribute__((external_source_symbol(defined_in="module" language="swift" generated_declaration))); // expected-error {{expected ')'}} expected-note {{to match this '('}}
73
74 void 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
77 void f22(void)
78 __attribute__((external_source_symbol)); // expected-error {{'external_source_symbol' attribute takes at least 1 argument}}
79
80 void 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
83 void f24(void)
84 __attribute__((external_source_symbol(language = generated_declaration))); // expected-error {{expected string literal for language name in 'external_source_symbol' attribute}}
85
86 void 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
89 void 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
92 void f27(void)
93 __attribute__((external_source_symbol(USR=f27))); // expected-error {{expected string literal for USR in 'external_source_symbol' attribute}}
94
95 void f28(void)
96 __attribute__((external_source_symbol(USR="")));
97
98 void f29(void)
99 __attribute__((external_source_symbol(language=L"Swift"))); // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect}}
100
101 void 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
105 void f31(void)
106 __attribute__((external_source_symbol(USR=u"foo"))); // expected-warning {{encoding prefix 'u' on an unevaluated string literal has no effect}}
107
108 void 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
112 void 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
115 void 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