annotate clang/test/Misc/pragma-attribute-strict-subjects.c @ 206:f17a3b42b08b

Added tag before-12 for changeset b7591485f4cd
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 07 Jun 2021 21:25:57 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -fsyntax-only -Wno-pragma-clang-attribute -verify %s
anatofuz
parents:
diff changeset
2 // RUN: not %clang_cc1 -fsyntax-only -ast-dump -ast-dump-filter test %s | FileCheck %s
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 // Check for contradictions in rules for attribute without a strict subject set:
anatofuz
parents:
diff changeset
5
anatofuz
parents:
diff changeset
6 #pragma clang attribute push (__attribute__((annotate("subRuleContradictions"))), apply_to = any(variable, variable(is_parameter), function(is_member), variable(is_global)))
anatofuz
parents:
diff changeset
7 // expected-error@-1 {{redundant attribute subject matcher sub-rule 'variable(is_parameter)'; 'variable' already matches those declarations}}
anatofuz
parents:
diff changeset
8 // expected-error@-2 {{redundant attribute subject matcher sub-rule 'variable(is_global)'; 'variable' already matches those declarations}}
anatofuz
parents:
diff changeset
9
anatofuz
parents:
diff changeset
10 // Ensure that we've recovered from the error:
anatofuz
parents:
diff changeset
11 int testRecoverSubRuleContradiction = 0;
anatofuz
parents:
diff changeset
12 // CHECK-LABEL: VarDecl{{.*}} testRecoverSubRuleContradiction
anatofuz
parents:
diff changeset
13 // CHECK-NEXT: IntegerLiteral
anatofuz
parents:
diff changeset
14 // CHECK-NEXT: AnnotateAttr{{.*}} "subRuleContradictions"
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 #pragma clang attribute pop
anatofuz
parents:
diff changeset
17
anatofuz
parents:
diff changeset
18 #pragma clang attribute push (__attribute__((annotate("negatedSubRuleContradictions2"))), apply_to = any(variable(unless(is_parameter)), variable(is_thread_local), function, variable(is_global)))
anatofuz
parents:
diff changeset
19 // expected-error@-1 {{negated attribute subject matcher sub-rule 'variable(unless(is_parameter))' contradicts sub-rule 'variable(is_global)'}}
anatofuz
parents:
diff changeset
20 // We have just one error, don't error on 'variable(is_global)'
anatofuz
parents:
diff changeset
21
anatofuz
parents:
diff changeset
22 // Ensure that we've recovered from the error:
anatofuz
parents:
diff changeset
23 int testRecoverNegatedContradiction = 0;
anatofuz
parents:
diff changeset
24 // CHECK-LABEL: VarDecl{{.*}} testRecoverNegatedContradiction
anatofuz
parents:
diff changeset
25 // CHECK-NEXT: IntegerLiteral
anatofuz
parents:
diff changeset
26 // CHECK-NEXT: AnnotateAttr{{.*}} "negatedSubRuleContradictions2"
anatofuz
parents:
diff changeset
27
anatofuz
parents:
diff changeset
28 void testRecoverNegatedContradictionFunc(void);
anatofuz
parents:
diff changeset
29 // CHECK-LABEL: FunctionDecl{{.*}} testRecoverNegatedContradictionFunc
anatofuz
parents:
diff changeset
30 // CHECK-NEXT: AnnotateAttr{{.*}} "negatedSubRuleContradictions2"
anatofuz
parents:
diff changeset
31
anatofuz
parents:
diff changeset
32 #pragma clang attribute pop
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 // Verify the strict subject set verification.
anatofuz
parents:
diff changeset
35
anatofuz
parents:
diff changeset
36 #pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = any(function))
anatofuz
parents:
diff changeset
37
anatofuz
parents:
diff changeset
38 int testRecoverStrictnessVar = 0;
anatofuz
parents:
diff changeset
39 // CHECK-LABEL: VarDecl{{.*}} testRecoverStrictnessVar
anatofuz
parents:
diff changeset
40 // CHECK-NEXT: IntegerLiteral
anatofuz
parents:
diff changeset
41 // CHECK-NOT: AbiTagAttr
anatofuz
parents:
diff changeset
42
anatofuz
parents:
diff changeset
43 void testRecoverStrictnessFunc(void);
anatofuz
parents:
diff changeset
44 // CHECK-LABEL: FunctionDecl{{.*}} testRecoverStrictnessFunc
anatofuz
parents:
diff changeset
45 // CHECK-NEXT: AbiTagAttr
anatofuz
parents:
diff changeset
46
anatofuz
parents:
diff changeset
47 struct testRecoverStrictnessStruct { };
anatofuz
parents:
diff changeset
48 // CHECK-LABEL: RecordDecl{{.*}} testRecoverStrictnessStruct
anatofuz
parents:
diff changeset
49 // CHECK-NOT: AbiTagAttr
anatofuz
parents:
diff changeset
50
anatofuz
parents:
diff changeset
51 #pragma clang attribute pop
anatofuz
parents:
diff changeset
52
anatofuz
parents:
diff changeset
53 #pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = any(function, record(unless(is_union)), variable, enum))
anatofuz
parents:
diff changeset
54 // expected-error@-1 {{attribute 'abi_tag' can't be applied to 'enum'}}
anatofuz
parents:
diff changeset
55
anatofuz
parents:
diff changeset
56 int testRecoverExtraVar = 0;
anatofuz
parents:
diff changeset
57 // CHECK-LABEL: VarDecl{{.*}} testRecoverExtraVar
anatofuz
parents:
diff changeset
58 // CHECK-NEXT: IntegerLiteral
anatofuz
parents:
diff changeset
59 // CHECK-NEXT: AbiTagAttr
anatofuz
parents:
diff changeset
60
anatofuz
parents:
diff changeset
61 void testRecoverExtraFunc(void);
anatofuz
parents:
diff changeset
62 // CHECK-LABEL: FunctionDecl{{.*}} testRecoverExtraFunc
anatofuz
parents:
diff changeset
63 // CHECK-NEXT: AbiTagAttr
anatofuz
parents:
diff changeset
64
anatofuz
parents:
diff changeset
65 struct testRecoverExtraStruct { };
anatofuz
parents:
diff changeset
66 // CHECK-LABEL: RecordDecl{{.*}} testRecoverExtraStruct
anatofuz
parents:
diff changeset
67 // CHECK-NEXT: AbiTagAttr
anatofuz
parents:
diff changeset
68
anatofuz
parents:
diff changeset
69 enum testNoEnumAbiTag { CaseCase };
anatofuz
parents:
diff changeset
70 // CHECK-LABEL: EnumDecl{{.*}} testNoEnumAbiTag
anatofuz
parents:
diff changeset
71 // CHECK-NO: AbiTagAttr
anatofuz
parents:
diff changeset
72
anatofuz
parents:
diff changeset
73 #pragma clang attribute pop
anatofuz
parents:
diff changeset
74
anatofuz
parents:
diff changeset
75 // Verify the non-strict subject set verification.
anatofuz
parents:
diff changeset
76
anatofuz
parents:
diff changeset
77 #pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = any(function))
anatofuz
parents:
diff changeset
78
anatofuz
parents:
diff changeset
79 int testSubset1Var;
anatofuz
parents:
diff changeset
80 // CHECK-LABEL: VarDecl{{.*}} testSubset1Var
anatofuz
parents:
diff changeset
81 // CHECK-NOT: AbiTagAttr
anatofuz
parents:
diff changeset
82
anatofuz
parents:
diff changeset
83 void testSubset1Func(void);
anatofuz
parents:
diff changeset
84 // CHECK-LABEL: FunctionDecl{{.*}} testSubset1Func
anatofuz
parents:
diff changeset
85 // CHECK-NEXT: AbiTagAttr
anatofuz
parents:
diff changeset
86
anatofuz
parents:
diff changeset
87 struct testSubset1Struct { };
anatofuz
parents:
diff changeset
88 // CHECK-LABEL: RecordDecl{{.*}} testSubset1Struct
anatofuz
parents:
diff changeset
89 // CHECK-NOT: AbiTagAttr
anatofuz
parents:
diff changeset
90
anatofuz
parents:
diff changeset
91 #pragma clang attribute pop
anatofuz
parents:
diff changeset
92
anatofuz
parents:
diff changeset
93 #pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = variable)
anatofuz
parents:
diff changeset
94
anatofuz
parents:
diff changeset
95 int testSubset2Var;
anatofuz
parents:
diff changeset
96 // CHECK-LABEL: VarDecl{{.*}} testSubset2Var
anatofuz
parents:
diff changeset
97 // CHECK-NEXT: AbiTagAttr
anatofuz
parents:
diff changeset
98
anatofuz
parents:
diff changeset
99 void testSubset2Func(void);
anatofuz
parents:
diff changeset
100 // CHECK-LABEL: FunctionDecl{{.*}} testSubset2Func
anatofuz
parents:
diff changeset
101 // CHECK-NOT: AbiTagAttr
anatofuz
parents:
diff changeset
102
anatofuz
parents:
diff changeset
103 struct testSubset2Struct { };
anatofuz
parents:
diff changeset
104 // CHECK-LABEL: RecordDecl{{.*}} testSubset2Struct
anatofuz
parents:
diff changeset
105 // CHECK-NOT: AbiTagAttr
anatofuz
parents:
diff changeset
106
anatofuz
parents:
diff changeset
107 #pragma clang attribute pop
anatofuz
parents:
diff changeset
108
anatofuz
parents:
diff changeset
109 #pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = any(record(unless(is_union))))
anatofuz
parents:
diff changeset
110
anatofuz
parents:
diff changeset
111 int testSubset3Var;
anatofuz
parents:
diff changeset
112 // CHECK-LABEL: VarDecl{{.*}} testSubset3Var
anatofuz
parents:
diff changeset
113 // CHECK-NOT: AbiTagAttr
anatofuz
parents:
diff changeset
114
anatofuz
parents:
diff changeset
115 void testSubset3Func(void);
anatofuz
parents:
diff changeset
116 // CHECK-LABEL: FunctionDecl{{.*}} testSubset3Func
anatofuz
parents:
diff changeset
117 // CHECK-NOT: AbiTagAttr
anatofuz
parents:
diff changeset
118
anatofuz
parents:
diff changeset
119 struct testSubset3Struct { };
anatofuz
parents:
diff changeset
120 // CHECK-LABEL: RecordDecl{{.*}} testSubset3Struct
anatofuz
parents:
diff changeset
121 // CHECK-NEXT: AbiTagAttr
anatofuz
parents:
diff changeset
122
anatofuz
parents:
diff changeset
123 #pragma clang attribute pop
anatofuz
parents:
diff changeset
124
anatofuz
parents:
diff changeset
125 #pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = any(function, variable))
anatofuz
parents:
diff changeset
126
anatofuz
parents:
diff changeset
127 int testSubset4Var;
anatofuz
parents:
diff changeset
128 // CHECK-LABEL: VarDecl{{.*}} testSubset4Var
anatofuz
parents:
diff changeset
129 // CHECK-NEXT: AbiTagAttr
anatofuz
parents:
diff changeset
130
anatofuz
parents:
diff changeset
131 void testSubset4Func(void);
anatofuz
parents:
diff changeset
132 // CHECK-LABEL: FunctionDecl{{.*}} testSubset4Func
anatofuz
parents:
diff changeset
133 // CHECK-NEXT: AbiTagAttr
anatofuz
parents:
diff changeset
134
anatofuz
parents:
diff changeset
135 struct testSubset4Struct { };
anatofuz
parents:
diff changeset
136 // CHECK-LABEL: RecordDecl{{.*}} testSubset4Struct
anatofuz
parents:
diff changeset
137 // CHECK-NOT: AbiTagAttr
anatofuz
parents:
diff changeset
138
anatofuz
parents:
diff changeset
139 #pragma clang attribute pop
anatofuz
parents:
diff changeset
140
anatofuz
parents:
diff changeset
141 #pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = any(variable, record(unless(is_union))))
anatofuz
parents:
diff changeset
142
anatofuz
parents:
diff changeset
143 int testSubset5Var;
anatofuz
parents:
diff changeset
144 // CHECK-LABEL: VarDecl{{.*}} testSubset5Var
anatofuz
parents:
diff changeset
145 // CHECK-NEXT: AbiTagAttr
anatofuz
parents:
diff changeset
146
anatofuz
parents:
diff changeset
147 void testSubset5Func(void);
anatofuz
parents:
diff changeset
148 // CHECK-LABEL: FunctionDecl{{.*}} testSubset5Func
anatofuz
parents:
diff changeset
149 // CHECK-NOT: AbiTagAttr
anatofuz
parents:
diff changeset
150
anatofuz
parents:
diff changeset
151 struct testSubset5Struct { };
anatofuz
parents:
diff changeset
152 // CHECK-LABEL: RecordDecl{{.*}} testSubset5Struct
anatofuz
parents:
diff changeset
153 // CHECK-NEXT: AbiTagAttr
anatofuz
parents:
diff changeset
154
anatofuz
parents:
diff changeset
155 #pragma clang attribute pop
anatofuz
parents:
diff changeset
156
anatofuz
parents:
diff changeset
157 #pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = any(record(unless(is_union)), function))
anatofuz
parents:
diff changeset
158
anatofuz
parents:
diff changeset
159 int testSubset6Var;
anatofuz
parents:
diff changeset
160 // CHECK-LABEL: VarDecl{{.*}} testSubset6Var
anatofuz
parents:
diff changeset
161 // CHECK-NOT: AbiTagAttr
anatofuz
parents:
diff changeset
162
anatofuz
parents:
diff changeset
163 void testSubset6Func(void);
anatofuz
parents:
diff changeset
164 // CHECK-LABEL: FunctionDecl{{.*}} testSubset6Func
anatofuz
parents:
diff changeset
165 // CHECK-NEXT: AbiTagAttr
anatofuz
parents:
diff changeset
166
anatofuz
parents:
diff changeset
167 struct testSubset6Struct { };
anatofuz
parents:
diff changeset
168 // CHECK-LABEL: RecordDecl{{.*}} testSubset6Struct
anatofuz
parents:
diff changeset
169 // CHECK-NEXT: AbiTagAttr
anatofuz
parents:
diff changeset
170
anatofuz
parents:
diff changeset
171 #pragma clang attribute pop
anatofuz
parents:
diff changeset
172
anatofuz
parents:
diff changeset
173 #pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = any(record(unless(is_union)), function, variable))
anatofuz
parents:
diff changeset
174
anatofuz
parents:
diff changeset
175 int testSubset7Var;
anatofuz
parents:
diff changeset
176 // CHECK-LABEL: VarDecl{{.*}} testSubset7Var
anatofuz
parents:
diff changeset
177 // CHECK-NEXT: AbiTagAttr
anatofuz
parents:
diff changeset
178
anatofuz
parents:
diff changeset
179 void testSubset7Func(void);
anatofuz
parents:
diff changeset
180 // CHECK-LABEL: FunctionDecl{{.*}} testSubset7Func
anatofuz
parents:
diff changeset
181 // CHECK-NEXT: AbiTagAttr
anatofuz
parents:
diff changeset
182
anatofuz
parents:
diff changeset
183 struct testSubset7Struct { };
anatofuz
parents:
diff changeset
184 // CHECK-LABEL: RecordDecl{{.*}} testSubset7Struct
anatofuz
parents:
diff changeset
185 // CHECK-NEXT: AbiTagAttr
anatofuz
parents:
diff changeset
186
anatofuz
parents:
diff changeset
187 #pragma clang attribute pop
anatofuz
parents:
diff changeset
188
anatofuz
parents:
diff changeset
189
anatofuz
parents:
diff changeset
190 #pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = any(record(unless(is_union)), function, variable, enum, enum_constant))
anatofuz
parents:
diff changeset
191 // expected-error@-1 {{attribute 'abi_tag' can't be applied to 'enum_constant', and 'enum'}}
anatofuz
parents:
diff changeset
192
anatofuz
parents:
diff changeset
193 int testSubsetRecoverVar;
anatofuz
parents:
diff changeset
194 // CHECK-LABEL: VarDecl{{.*}} testSubsetRecoverVar
anatofuz
parents:
diff changeset
195 // CHECK-NEXT: AbiTagAttr
anatofuz
parents:
diff changeset
196
anatofuz
parents:
diff changeset
197 void testSubsetRecoverFunc(void);
anatofuz
parents:
diff changeset
198 // CHECK-LABEL: FunctionDecl{{.*}} testSubsetRecoverFunc
anatofuz
parents:
diff changeset
199 // CHECK-NEXT: AbiTagAttr
anatofuz
parents:
diff changeset
200
anatofuz
parents:
diff changeset
201 struct testSubsetRecoverStruct { };
anatofuz
parents:
diff changeset
202 // CHECK-LABEL: RecordDecl{{.*}} testSubsetRecoverStruct
anatofuz
parents:
diff changeset
203 // CHECK-NEXT: AbiTagAttr
anatofuz
parents:
diff changeset
204
anatofuz
parents:
diff changeset
205 #pragma clang attribute pop
anatofuz
parents:
diff changeset
206
anatofuz
parents:
diff changeset
207 #pragma clang attribute push (__attribute__((abi_tag("a"))), apply_to = enum)
anatofuz
parents:
diff changeset
208 // expected-error@-1 {{attribute 'abi_tag' can't be applied to 'enum'}}
anatofuz
parents:
diff changeset
209
anatofuz
parents:
diff changeset
210 int testSubsetNoVar;
anatofuz
parents:
diff changeset
211 // CHECK-LABEL: VarDecl{{.*}} testSubsetNoVar
anatofuz
parents:
diff changeset
212 // CHECK-NOT: AbiTagAttr
anatofuz
parents:
diff changeset
213
anatofuz
parents:
diff changeset
214 void testSubsetNoFunc(void);
anatofuz
parents:
diff changeset
215 // CHECK-LABEL: FunctionDecl{{.*}} testSubsetNoFunc
anatofuz
parents:
diff changeset
216 // CHECK-NOT: AbiTagAttr
anatofuz
parents:
diff changeset
217
anatofuz
parents:
diff changeset
218 struct testSubsetNoStruct { };
anatofuz
parents:
diff changeset
219 // CHECK-LABEL: RecordDecl{{.*}} testSubsetNoStruct
anatofuz
parents:
diff changeset
220 // CHECK-NOT: AbiTagAttr
anatofuz
parents:
diff changeset
221
anatofuz
parents:
diff changeset
222 #pragma clang attribute pop