annotate clang/test/Parser/MicrosoftExtensions.cpp @ 266:00f31e85ec16 default tip

Added tag current for changeset 31d058e83c98
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 14 Oct 2023 10:13:55 +0900
parents c4bab56944e8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 %s -triple i386-pc-win32 -std=c++14 -fsyntax-only -Wno-unused-getter-return-value -Wno-unused-value -Wmicrosoft -verify -fms-extensions -fms-compatibility -fdelayed-template-parsing
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 /* Microsoft attribute tests */
anatofuz
parents:
diff changeset
4 [repeatable][source_annotation_attribute( Parameter|ReturnValue )]
anatofuz
parents:
diff changeset
5 struct SA_Post{ SA_Post(); int attr; };
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 [returnvalue:SA_Post( attr=1)]
anatofuz
parents:
diff changeset
8 int foo1([SA_Post(attr=1)] void *param);
anatofuz
parents:
diff changeset
9
anatofuz
parents:
diff changeset
10 namespace {
anatofuz
parents:
diff changeset
11 [returnvalue:SA_Post(attr=1)]
anatofuz
parents:
diff changeset
12 int foo2([SA_Post(attr=1)] void *param);
anatofuz
parents:
diff changeset
13 }
anatofuz
parents:
diff changeset
14
anatofuz
parents:
diff changeset
15 class T {
anatofuz
parents:
diff changeset
16 [returnvalue:SA_Post(attr=1)]
anatofuz
parents:
diff changeset
17 int foo3([SA_Post(attr=1)] void *param);
anatofuz
parents:
diff changeset
18 };
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 extern "C" {
anatofuz
parents:
diff changeset
21 [returnvalue:SA_Post(attr=1)]
anatofuz
parents:
diff changeset
22 int foo5([SA_Post(attr=1)] void *param);
anatofuz
parents:
diff changeset
23 }
anatofuz
parents:
diff changeset
24
anatofuz
parents:
diff changeset
25 class class_attr {
anatofuz
parents:
diff changeset
26 public:
anatofuz
parents:
diff changeset
27 class_attr([SA_Pre(Null=SA_No,NullTerminated=SA_Yes)] int a)
anatofuz
parents:
diff changeset
28 {
anatofuz
parents:
diff changeset
29 }
anatofuz
parents:
diff changeset
30 };
anatofuz
parents:
diff changeset
31
anatofuz
parents:
diff changeset
32
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 void uuidof_test1()
anatofuz
parents:
diff changeset
35 {
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
36 __uuidof(0);
150
anatofuz
parents:
diff changeset
37 }
anatofuz
parents:
diff changeset
38
anatofuz
parents:
diff changeset
39 typedef struct _GUID
anatofuz
parents:
diff changeset
40 {
anatofuz
parents:
diff changeset
41 unsigned long Data1;
anatofuz
parents:
diff changeset
42 unsigned short Data2;
anatofuz
parents:
diff changeset
43 unsigned short Data3;
anatofuz
parents:
diff changeset
44 unsigned char Data4[8];
anatofuz
parents:
diff changeset
45 } GUID;
anatofuz
parents:
diff changeset
46
anatofuz
parents:
diff changeset
47 struct __declspec(uuid(L"00000000-0000-0000-1234-000000000047")) uuid_attr_bad1 { };// expected-error {{'uuid' attribute requires a string}}
anatofuz
parents:
diff changeset
48 struct __declspec(uuid(3)) uuid_attr_bad2 { };// expected-error {{'uuid' attribute requires a string}}
anatofuz
parents:
diff changeset
49 struct __declspec(uuid("0000000-0000-0000-1234-0000500000047")) uuid_attr_bad3 { };// expected-error {{uuid attribute contains a malformed GUID}}
anatofuz
parents:
diff changeset
50 struct __declspec(uuid("0000000-0000-0000-Z234-000000000047")) uuid_attr_bad4 { };// expected-error {{uuid attribute contains a malformed GUID}}
anatofuz
parents:
diff changeset
51 struct __declspec(uuid("000000000000-0000-1234-000000000047")) uuid_attr_bad5 { };// expected-error {{uuid attribute contains a malformed GUID}}
anatofuz
parents:
diff changeset
52 [uuid("000000000000-0000-1234-000000000047")] struct uuid_attr_bad6 { };// expected-error {{uuid attribute contains a malformed GUID}}
anatofuz
parents:
diff changeset
53
anatofuz
parents:
diff changeset
54 __declspec(uuid("000000A0-0000-0000-C000-000000000046")) int i; // expected-warning {{'uuid' attribute only applies to structs, unions, classes, and enums}}
anatofuz
parents:
diff changeset
55
anatofuz
parents:
diff changeset
56 struct __declspec(uuid("000000A0-0000-0000-C000-000000000046"))
anatofuz
parents:
diff changeset
57 struct_with_uuid { };
anatofuz
parents:
diff changeset
58 struct struct_without_uuid { };
anatofuz
parents:
diff changeset
59
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
60 struct base {
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
61 int a;
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
62 };
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
63 struct derived : base {
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
64 // Can't apply a UUID to a using declaration.
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
65 [uuid("000000A0-0000-0000-C000-00000000004A")] using base::a; // expected-error {{expected member name}}
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
66 };
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
67
150
anatofuz
parents:
diff changeset
68 struct __declspec(uuid("000000A0-0000-0000-C000-000000000049"))
anatofuz
parents:
diff changeset
69 struct_with_uuid2;
anatofuz
parents:
diff changeset
70
anatofuz
parents:
diff changeset
71 [uuid("000000A0-0000-0000-C000-000000000049")] struct struct_with_uuid3; // expected-warning{{specifying 'uuid' as an ATL attribute is deprecated; use __declspec instead}}
anatofuz
parents:
diff changeset
72
anatofuz
parents:
diff changeset
73 struct
anatofuz
parents:
diff changeset
74 struct_with_uuid2 {} ;
anatofuz
parents:
diff changeset
75
anatofuz
parents:
diff changeset
76 enum __declspec(uuid("000000A0-0000-0000-C000-000000000046"))
anatofuz
parents:
diff changeset
77 enum_with_uuid { };
anatofuz
parents:
diff changeset
78 enum enum_without_uuid { };
anatofuz
parents:
diff changeset
79
anatofuz
parents:
diff changeset
80 int __declspec(uuid("000000A0-0000-0000-C000-000000000046")) inappropriate_uuid; // expected-warning {{'uuid' attribute only applies to}}
anatofuz
parents:
diff changeset
81
anatofuz
parents:
diff changeset
82 int uuid_sema_test()
anatofuz
parents:
diff changeset
83 {
anatofuz
parents:
diff changeset
84 struct_with_uuid var_with_uuid[1];
anatofuz
parents:
diff changeset
85 struct_without_uuid var_without_uuid[1];
anatofuz
parents:
diff changeset
86
anatofuz
parents:
diff changeset
87 __uuidof(struct_with_uuid);
anatofuz
parents:
diff changeset
88 __uuidof(struct_with_uuid2);
anatofuz
parents:
diff changeset
89 __uuidof(struct_with_uuid3);
anatofuz
parents:
diff changeset
90 __uuidof(struct_without_uuid); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
anatofuz
parents:
diff changeset
91 __uuidof(struct_with_uuid*);
anatofuz
parents:
diff changeset
92 __uuidof(struct_without_uuid*); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
anatofuz
parents:
diff changeset
93 __uuidof(struct_with_uuid[1]);
anatofuz
parents:
diff changeset
94 __uuidof(struct_with_uuid*[1]); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
anatofuz
parents:
diff changeset
95 __uuidof(const struct_with_uuid[1][1]);
anatofuz
parents:
diff changeset
96 __uuidof(const struct_with_uuid*[1][1]); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
anatofuz
parents:
diff changeset
97
anatofuz
parents:
diff changeset
98 __uuidof(enum_with_uuid);
anatofuz
parents:
diff changeset
99 __uuidof(enum_without_uuid); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
anatofuz
parents:
diff changeset
100 __uuidof(enum_with_uuid*);
anatofuz
parents:
diff changeset
101 __uuidof(enum_without_uuid*); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
anatofuz
parents:
diff changeset
102 __uuidof(enum_with_uuid[1]);
anatofuz
parents:
diff changeset
103 __uuidof(enum_with_uuid*[1]); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
anatofuz
parents:
diff changeset
104 __uuidof(const enum_with_uuid[1][1]);
anatofuz
parents:
diff changeset
105 __uuidof(const enum_with_uuid*[1][1]); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
anatofuz
parents:
diff changeset
106
anatofuz
parents:
diff changeset
107 __uuidof(var_with_uuid);
anatofuz
parents:
diff changeset
108 __uuidof(var_without_uuid);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
anatofuz
parents:
diff changeset
109 __uuidof(var_with_uuid[1]);
anatofuz
parents:
diff changeset
110 __uuidof(var_without_uuid[1]);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
anatofuz
parents:
diff changeset
111 __uuidof(&var_with_uuid[1]);
anatofuz
parents:
diff changeset
112 __uuidof(&var_without_uuid[1]);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
anatofuz
parents:
diff changeset
113
anatofuz
parents:
diff changeset
114 __uuidof(0);
anatofuz
parents:
diff changeset
115 __uuidof(1);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
anatofuz
parents:
diff changeset
116 }
anatofuz
parents:
diff changeset
117
anatofuz
parents:
diff changeset
118
anatofuz
parents:
diff changeset
119 template <class T>
anatofuz
parents:
diff changeset
120 void template_uuid()
anatofuz
parents:
diff changeset
121 {
anatofuz
parents:
diff changeset
122 T expr;
anatofuz
parents:
diff changeset
123
anatofuz
parents:
diff changeset
124 __uuidof(T);
anatofuz
parents:
diff changeset
125 __uuidof(expr);
anatofuz
parents:
diff changeset
126 }
anatofuz
parents:
diff changeset
127
anatofuz
parents:
diff changeset
128
anatofuz
parents:
diff changeset
129 template <class T, const GUID* g = &__uuidof(T)> // expected-note {{template parameter is declared here}}
anatofuz
parents:
diff changeset
130 class COM_CLASS_TEMPLATE { };
anatofuz
parents:
diff changeset
131
anatofuz
parents:
diff changeset
132 typedef COM_CLASS_TEMPLATE<struct_with_uuid, &*&__uuidof(struct_with_uuid)> COM_TYPE_1; // expected-warning {{non-type template argument containing a dereference operation is a Microsoft extension}}
anatofuz
parents:
diff changeset
133 typedef COM_CLASS_TEMPLATE<struct_with_uuid> COM_TYPE_2;
anatofuz
parents:
diff changeset
134
anatofuz
parents:
diff changeset
135 template <class T, const GUID& g>
anatofuz
parents:
diff changeset
136 class COM_CLASS_TEMPLATE_REF { };
anatofuz
parents:
diff changeset
137 typedef COM_CLASS_TEMPLATE_REF<struct_with_uuid, __uuidof(struct_with_uuid)> COM_TYPE_REF;
anatofuz
parents:
diff changeset
138
anatofuz
parents:
diff changeset
139 struct late_defined_uuid;
anatofuz
parents:
diff changeset
140 template<typename T>
anatofuz
parents:
diff changeset
141 void test_late_defined_uuid() {
anatofuz
parents:
diff changeset
142 __uuidof(late_defined_uuid);
anatofuz
parents:
diff changeset
143 }
anatofuz
parents:
diff changeset
144 struct __declspec(uuid("000000A0-0000-0000-C000-000000000049")) late_defined_uuid;
anatofuz
parents:
diff changeset
145
anatofuz
parents:
diff changeset
146 COM_CLASS_TEMPLATE_REF<int, __uuidof(struct_with_uuid)> good_template_arg;
anatofuz
parents:
diff changeset
147
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
148 COM_CLASS_TEMPLATE<int, __uuidof(struct_with_uuid)> bad_template_arg; // expected-error {{non-type template argument for template parameter of pointer type 'const GUID *' (aka 'const _GUID *') must have its address taken}}
150
anatofuz
parents:
diff changeset
149
anatofuz
parents:
diff changeset
150 namespace PR16911 {
anatofuz
parents:
diff changeset
151 struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid;
anatofuz
parents:
diff changeset
152 struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid2;
anatofuz
parents:
diff changeset
153
anatofuz
parents:
diff changeset
154 template <typename T, typename T2>
anatofuz
parents:
diff changeset
155 struct thing {
anatofuz
parents:
diff changeset
156 };
anatofuz
parents:
diff changeset
157
anatofuz
parents:
diff changeset
158 struct empty {};
anatofuz
parents:
diff changeset
159 struct inher : public thing<empty, uuid2> {};
anatofuz
parents:
diff changeset
160
anatofuz
parents:
diff changeset
161 struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid;
anatofuz
parents:
diff changeset
162 const struct _GUID *w = &__uuidof(inher); // expected-error{{cannot call operator __uuidof on a type with no GUID}}
anatofuz
parents:
diff changeset
163 const struct _GUID *x = &__uuidof(thing<uuid, inher>);
anatofuz
parents:
diff changeset
164 const struct _GUID *y = &__uuidof(thing<uuid2, uuid>); // expected-error{{cannot call operator __uuidof on a type with multiple GUIDs}}
anatofuz
parents:
diff changeset
165 thing<uuid2, uuid> thing_obj = thing<uuid2, uuid>();
anatofuz
parents:
diff changeset
166 const struct _GUID *z = &__uuidof(thing_obj); // expected-error{{cannot call operator __uuidof on a type with multiple GUIDs}}
anatofuz
parents:
diff changeset
167 }
anatofuz
parents:
diff changeset
168
anatofuz
parents:
diff changeset
169 class CtorCall {
anatofuz
parents:
diff changeset
170 public:
anatofuz
parents:
diff changeset
171 CtorCall& operator=(const CtorCall& that);
anatofuz
parents:
diff changeset
172
anatofuz
parents:
diff changeset
173 int a;
anatofuz
parents:
diff changeset
174 };
anatofuz
parents:
diff changeset
175
anatofuz
parents:
diff changeset
176 CtorCall& CtorCall::operator=(const CtorCall& that)
anatofuz
parents:
diff changeset
177 {
anatofuz
parents:
diff changeset
178 if (this != &that) {
anatofuz
parents:
diff changeset
179 this->CtorCall::~CtorCall();
anatofuz
parents:
diff changeset
180 this->CtorCall::CtorCall(that); // expected-warning {{explicit constructor calls are a Microsoft extension}}
anatofuz
parents:
diff changeset
181 }
anatofuz
parents:
diff changeset
182 return *this;
anatofuz
parents:
diff changeset
183 }
anatofuz
parents:
diff changeset
184
anatofuz
parents:
diff changeset
185 template <class A>
anatofuz
parents:
diff changeset
186 class C1 {
anatofuz
parents:
diff changeset
187 public:
anatofuz
parents:
diff changeset
188 template <int B>
anatofuz
parents:
diff changeset
189 class Iterator {
anatofuz
parents:
diff changeset
190 };
anatofuz
parents:
diff changeset
191 };
anatofuz
parents:
diff changeset
192
anatofuz
parents:
diff changeset
193 template<class T>
anatofuz
parents:
diff changeset
194 class C2 {
anatofuz
parents:
diff changeset
195 typename C1<T>:: /*template*/ Iterator<0> Mypos; // expected-warning {{use 'template' keyword to treat 'Iterator' as a dependent template name}}
anatofuz
parents:
diff changeset
196 };
anatofuz
parents:
diff changeset
197
anatofuz
parents:
diff changeset
198 template <class T>
anatofuz
parents:
diff changeset
199 void missing_template_keyword(){
anatofuz
parents:
diff changeset
200 typename C1<T>:: /*template*/ Iterator<0> Mypos; // expected-warning {{use 'template' keyword to treat 'Iterator' as a dependent template name}}
anatofuz
parents:
diff changeset
201 }
anatofuz
parents:
diff changeset
202
anatofuz
parents:
diff changeset
203
anatofuz
parents:
diff changeset
204
anatofuz
parents:
diff changeset
205 class AAAA {
anatofuz
parents:
diff changeset
206 typedef int D;
anatofuz
parents:
diff changeset
207 };
anatofuz
parents:
diff changeset
208
anatofuz
parents:
diff changeset
209 template <typename T>
anatofuz
parents:
diff changeset
210 class SimpleTemplate {};
anatofuz
parents:
diff changeset
211
anatofuz
parents:
diff changeset
212 template <class T>
anatofuz
parents:
diff changeset
213 void redundant_typename() {
anatofuz
parents:
diff changeset
214 typename T t;// expected-warning {{expected a qualified name after 'typename'}}
anatofuz
parents:
diff changeset
215 typename AAAA a;// expected-warning {{expected a qualified name after 'typename'}}
anatofuz
parents:
diff changeset
216
anatofuz
parents:
diff changeset
217 t = 3;
anatofuz
parents:
diff changeset
218
anatofuz
parents:
diff changeset
219 typedef typename T* pointerT;// expected-warning {{expected a qualified name after 'typename'}}
anatofuz
parents:
diff changeset
220 typedef typename SimpleTemplate<int> templateT;// expected-warning {{expected a qualified name after 'typename'}}
anatofuz
parents:
diff changeset
221
anatofuz
parents:
diff changeset
222 pointerT pT = &t;
anatofuz
parents:
diff changeset
223 *pT = 4;
anatofuz
parents:
diff changeset
224
anatofuz
parents:
diff changeset
225 int var;
anatofuz
parents:
diff changeset
226 int k = typename var;// expected-error {{expected a qualified name after 'typename'}}
anatofuz
parents:
diff changeset
227 }
anatofuz
parents:
diff changeset
228
anatofuz
parents:
diff changeset
229 template <typename T>
anatofuz
parents:
diff changeset
230 struct TypenameWrongPlace {
anatofuz
parents:
diff changeset
231 typename typedef T::D D;// expected-warning {{expected a qualified name after 'typename'}}
anatofuz
parents:
diff changeset
232 };
anatofuz
parents:
diff changeset
233
anatofuz
parents:
diff changeset
234 extern TypenameWrongPlace<AAAA> PR16925;
anatofuz
parents:
diff changeset
235
anatofuz
parents:
diff changeset
236 __interface MicrosoftInterface;
anatofuz
parents:
diff changeset
237 __interface MicrosoftInterface {
anatofuz
parents:
diff changeset
238 void foo1() = 0; // expected-note {{overridden virtual function is here}}
anatofuz
parents:
diff changeset
239 virtual void foo2() = 0;
anatofuz
parents:
diff changeset
240 };
anatofuz
parents:
diff changeset
241
anatofuz
parents:
diff changeset
242 __interface MicrosoftDerivedInterface : public MicrosoftInterface {
anatofuz
parents:
diff changeset
243 void foo1(); // expected-warning {{'foo1' overrides a member function but is not marked 'override'}}
anatofuz
parents:
diff changeset
244 void foo2() override;
anatofuz
parents:
diff changeset
245 void foo3();
anatofuz
parents:
diff changeset
246 };
anatofuz
parents:
diff changeset
247
anatofuz
parents:
diff changeset
248 void interface_test() {
anatofuz
parents:
diff changeset
249 MicrosoftInterface* a;
anatofuz
parents:
diff changeset
250 a->foo1();
anatofuz
parents:
diff changeset
251 MicrosoftDerivedInterface* b;
anatofuz
parents:
diff changeset
252 b->foo2();
anatofuz
parents:
diff changeset
253 }
anatofuz
parents:
diff changeset
254
anatofuz
parents:
diff changeset
255 __int64 x7 = __int64(0);
anatofuz
parents:
diff changeset
256 _int64 x8 = _int64(0);
anatofuz
parents:
diff changeset
257 static_assert(sizeof(_int64) == 8, "");
anatofuz
parents:
diff changeset
258 static_assert(sizeof(_int32) == 4, "");
anatofuz
parents:
diff changeset
259 static_assert(sizeof(_int16) == 2, "");
anatofuz
parents:
diff changeset
260 static_assert(sizeof(_int8) == 1, "");
anatofuz
parents:
diff changeset
261
anatofuz
parents:
diff changeset
262 int __identifier(generic) = 3;
anatofuz
parents:
diff changeset
263 int __identifier(int) = 4;
anatofuz
parents:
diff changeset
264 struct __identifier(class) { __identifier(class) *__identifier(for); };
anatofuz
parents:
diff changeset
265 __identifier(class) __identifier(struct) = { &__identifier(struct) };
anatofuz
parents:
diff changeset
266
anatofuz
parents:
diff changeset
267 int __identifier for; // expected-error {{missing '(' after '__identifier'}}
anatofuz
parents:
diff changeset
268 int __identifier(else} = __identifier(for); // expected-error {{missing ')' after identifier}} expected-note {{to match this '('}}
anatofuz
parents:
diff changeset
269 #define identifier_weird(x) __identifier(x
anatofuz
parents:
diff changeset
270 int k = identifier_weird(if)); // expected-error {{use of undeclared identifier 'if'}}
anatofuz
parents:
diff changeset
271
anatofuz
parents:
diff changeset
272 extern int __identifier(and);
anatofuz
parents:
diff changeset
273
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
274 int __identifier("baz") = 0;
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
275 int bar = baz;
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
276
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
277 void mangled_function();
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
278 extern "C" void __identifier("?mangled_function@@YAXXZ")() {}
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
279
150
anatofuz
parents:
diff changeset
280 void f() {
anatofuz
parents:
diff changeset
281 __identifier(() // expected-error {{cannot convert '(' token to an identifier}}
anatofuz
parents:
diff changeset
282 __identifier(void) // expected-error {{use of undeclared identifier 'void'}}
anatofuz
parents:
diff changeset
283 __identifier()) // expected-error {{cannot convert ')' token to an identifier}}
anatofuz
parents:
diff changeset
284 // FIXME: We should pick a friendlier display name for this token kind.
anatofuz
parents:
diff changeset
285 __identifier(1) // expected-error {{cannot convert <numeric_constant> token to an identifier}}
anatofuz
parents:
diff changeset
286 __identifier(+) // expected-error {{cannot convert '+' token to an identifier}}
anatofuz
parents:
diff changeset
287 __identifier(;) // expected-error {{cannot convert ';' token to an identifier}}
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
288 __identifier("1"); // expected-error {{use of undeclared identifier '1'}}
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
289 __identifier("+"); // expected-error {{use of undeclared identifier '+'}}
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
290 __identifier(";"); // expected-error {{use of undeclared identifier ';'}}
150
anatofuz
parents:
diff changeset
291 }
anatofuz
parents:
diff changeset
292
anatofuz
parents:
diff changeset
293 class inline_definition_pure_spec {
anatofuz
parents:
diff changeset
294 virtual int f() = 0 { return 0; }// expected-warning {{function definition with pure-specifier is a Microsoft extension}}
anatofuz
parents:
diff changeset
295 virtual int f2() = 0;
anatofuz
parents:
diff changeset
296 };
anatofuz
parents:
diff changeset
297
anatofuz
parents:
diff changeset
298 struct pure_virtual_dtor {
anatofuz
parents:
diff changeset
299 virtual ~pure_virtual_dtor() = 0;
anatofuz
parents:
diff changeset
300 };
anatofuz
parents:
diff changeset
301 pure_virtual_dtor::~pure_virtual_dtor() { }
anatofuz
parents:
diff changeset
302
anatofuz
parents:
diff changeset
303 struct pure_virtual_dtor_inline {
anatofuz
parents:
diff changeset
304 virtual ~pure_virtual_dtor_inline() = 0 { }// expected-warning {{function definition with pure-specifier is a Microsoft extension}}
anatofuz
parents:
diff changeset
305 };
anatofuz
parents:
diff changeset
306
anatofuz
parents:
diff changeset
307 template<typename T> struct pure_virtual_dtor_template {
anatofuz
parents:
diff changeset
308 virtual ~pure_virtual_dtor_template() = 0;
anatofuz
parents:
diff changeset
309 };
anatofuz
parents:
diff changeset
310 template<typename T> pure_virtual_dtor_template<T>::~pure_virtual_dtor_template() {}
anatofuz
parents:
diff changeset
311 template struct pure_virtual_dtor_template<int>;
anatofuz
parents:
diff changeset
312
anatofuz
parents:
diff changeset
313 template<typename T> struct pure_virtual_dtor_template_inline {
anatofuz
parents:
diff changeset
314 virtual ~pure_virtual_dtor_template_inline() = 0 {}
anatofuz
parents:
diff changeset
315 // expected-warning@-1 2{{function definition with pure-specifier is a Microsoft extension}}
anatofuz
parents:
diff changeset
316 };
anatofuz
parents:
diff changeset
317 template struct pure_virtual_dtor_template_inline<int>;
anatofuz
parents:
diff changeset
318 // expected-note@-1 {{in instantiation of member function}}
anatofuz
parents:
diff changeset
319
anatofuz
parents:
diff changeset
320 int main () {
anatofuz
parents:
diff changeset
321 // Necessary to force instantiation in -fdelayed-template-parsing mode.
anatofuz
parents:
diff changeset
322 test_late_defined_uuid<int>();
anatofuz
parents:
diff changeset
323 redundant_typename<int>();
anatofuz
parents:
diff changeset
324 missing_template_keyword<int>();
anatofuz
parents:
diff changeset
325 }
anatofuz
parents:
diff changeset
326
anatofuz
parents:
diff changeset
327 namespace access_protected_PTM {
anatofuz
parents:
diff changeset
328 class A {
anatofuz
parents:
diff changeset
329 protected:
anatofuz
parents:
diff changeset
330 void f(); // expected-note {{must name member using the type of the current context 'access_protected_PTM::B'}}
anatofuz
parents:
diff changeset
331 };
anatofuz
parents:
diff changeset
332
anatofuz
parents:
diff changeset
333 class B : public A{
anatofuz
parents:
diff changeset
334 public:
anatofuz
parents:
diff changeset
335 void test_access();
anatofuz
parents:
diff changeset
336 static void test_access_static();
anatofuz
parents:
diff changeset
337 };
anatofuz
parents:
diff changeset
338
anatofuz
parents:
diff changeset
339 void B::test_access() {
anatofuz
parents:
diff changeset
340 &A::f; // expected-error {{'f' is a protected member of 'access_protected_PTM::A'}}
anatofuz
parents:
diff changeset
341 }
anatofuz
parents:
diff changeset
342
anatofuz
parents:
diff changeset
343 void B::test_access_static() {
anatofuz
parents:
diff changeset
344 &A::f;
anatofuz
parents:
diff changeset
345 }
anatofuz
parents:
diff changeset
346 }
anatofuz
parents:
diff changeset
347
anatofuz
parents:
diff changeset
348 namespace Inheritance {
anatofuz
parents:
diff changeset
349 class __single_inheritance A;
anatofuz
parents:
diff changeset
350 class __multiple_inheritance B;
anatofuz
parents:
diff changeset
351 class __virtual_inheritance C;
anatofuz
parents:
diff changeset
352 }
anatofuz
parents:
diff changeset
353
anatofuz
parents:
diff changeset
354 struct StructWithProperty {
anatofuz
parents:
diff changeset
355 __declspec(property) int V0; // expected-error {{expected '(' after 'property'}}
anatofuz
parents:
diff changeset
356 __declspec(property()) int V1; // expected-error {{property does not specify a getter or a putter}}
anatofuz
parents:
diff changeset
357 __declspec(property(set)) int V2; // expected-error {{putter for property must be specified as 'put', not 'set'}} expected-error {{expected '=' after 'set'}}
anatofuz
parents:
diff changeset
358 __declspec(property(ptu)) int V3; // expected-error {{missing 'get=' or 'put='}}
anatofuz
parents:
diff changeset
359 __declspec(property(ptu=PutV)) int V4; // expected-error {{expected 'get' or 'put' in property declaration}}
anatofuz
parents:
diff changeset
360 __declspec(property(get)) int V5; // expected-error {{expected '=' after 'get'}}
anatofuz
parents:
diff changeset
361 __declspec(property(get&)) int V6; // expected-error {{expected '=' after 'get'}}
anatofuz
parents:
diff changeset
362 __declspec(property(get=)) int V7; // expected-error {{expected name of accessor method}}
anatofuz
parents:
diff changeset
363 __declspec(property(get=GetV)) int V8; // no-warning
anatofuz
parents:
diff changeset
364 __declspec(property(get=GetV=)) int V9; // expected-error {{expected ',' or ')' at end of property accessor list}}
anatofuz
parents:
diff changeset
365 __declspec(property(get=GetV,)) int V10; // expected-error {{expected 'get' or 'put' in property declaration}}
anatofuz
parents:
diff changeset
366 __declspec(property(get=GetV,put=SetV)) int V11; // no-warning
anatofuz
parents:
diff changeset
367 __declspec(property(get=GetV,put=SetV,get=GetV)) int V12; // expected-error {{property declaration specifies 'get' accessor twice}}
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
368 __declspec(property(get=GetV)) int V13 = 3; // expected-error {{property declaration cannot have a default member initializer}}
150
anatofuz
parents:
diff changeset
369
anatofuz
parents:
diff changeset
370 int GetV() { return 123; }
anatofuz
parents:
diff changeset
371 void SetV(int v) {}
anatofuz
parents:
diff changeset
372 };
anatofuz
parents:
diff changeset
373 void TestProperty() {
anatofuz
parents:
diff changeset
374 StructWithProperty sp;
anatofuz
parents:
diff changeset
375 sp.V8;
anatofuz
parents:
diff changeset
376 sp.V8 = 0; // expected-error {{no setter defined for property 'V8'}}
anatofuz
parents:
diff changeset
377 int i = sp.V11;
anatofuz
parents:
diff changeset
378 sp.V11 = i++;
anatofuz
parents:
diff changeset
379 sp.V11 += 8;
anatofuz
parents:
diff changeset
380 sp.V11++;
anatofuz
parents:
diff changeset
381 ++sp.V11;
anatofuz
parents:
diff changeset
382 }
anatofuz
parents:
diff changeset
383
anatofuz
parents:
diff changeset
384 //expected-warning@+1 {{C++ operator 'and' (aka '&&') used as a macro name}}
anatofuz
parents:
diff changeset
385 #define and foo
anatofuz
parents:
diff changeset
386
anatofuz
parents:
diff changeset
387 struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) __declspec(novtable) IUnknown {};
anatofuz
parents:
diff changeset
388
anatofuz
parents:
diff changeset
389 typedef bool (__stdcall __stdcall *blarg)(int);
anatofuz
parents:
diff changeset
390
anatofuz
parents:
diff changeset
391 void local_callconv() {
anatofuz
parents:
diff changeset
392 bool (__stdcall *p)(int);
anatofuz
parents:
diff changeset
393 }
anatofuz
parents:
diff changeset
394
anatofuz
parents:
diff changeset
395 struct S7 {
anatofuz
parents:
diff changeset
396 int foo() { return 12; }
anatofuz
parents:
diff changeset
397 __declspec(property(get=foo) deprecated) int t; // expected-note {{'t' has been explicitly marked deprecated here}}
anatofuz
parents:
diff changeset
398 };
anatofuz
parents:
diff changeset
399
anatofuz
parents:
diff changeset
400 // Technically, this is legal (though it does nothing)
anatofuz
parents:
diff changeset
401 __declspec() void quux( void ) {
anatofuz
parents:
diff changeset
402 struct S7 s;
anatofuz
parents:
diff changeset
403 int i = s.t; // expected-warning {{'t' is deprecated}}
anatofuz
parents:
diff changeset
404 }
anatofuz
parents:
diff changeset
405
anatofuz
parents:
diff changeset
406 void *_alloca(int);
anatofuz
parents:
diff changeset
407
anatofuz
parents:
diff changeset
408 void foo(void) {
anatofuz
parents:
diff changeset
409 __declspec(align(16)) int *buffer = (int *)_alloca(9);
anatofuz
parents:
diff changeset
410 }
anatofuz
parents:
diff changeset
411
anatofuz
parents:
diff changeset
412 template <int *>
anatofuz
parents:
diff changeset
413 struct NullptrArg {};
anatofuz
parents:
diff changeset
414 NullptrArg<nullptr> a;
anatofuz
parents:
diff changeset
415
anatofuz
parents:
diff changeset
416 // Ignored type qualifiers after comma in declarator lists
anatofuz
parents:
diff changeset
417 typedef int ignored_quals_dummy1, const volatile __ptr32 __ptr64 __w64 __unaligned __sptr __uptr ignored_quals1; // expected-warning {{qualifiers after comma in declarator list are ignored}}
anatofuz
parents:
diff changeset
418 typedef void(*ignored_quals_dummy2)(), __fastcall ignored_quals2; // expected-warning {{qualifiers after comma in declarator list are ignored}}
anatofuz
parents:
diff changeset
419 typedef void(*ignored_quals_dummy3)(), __stdcall ignored_quals3; // expected-warning {{qualifiers after comma in declarator list are ignored}}
anatofuz
parents:
diff changeset
420 typedef void(*ignored_quals_dummy4)(), __thiscall ignored_quals4; // expected-warning {{qualifiers after comma in declarator list are ignored}}
anatofuz
parents:
diff changeset
421 typedef void(*ignored_quals_dummy5)(), __cdecl ignored_quals5; // expected-warning {{qualifiers after comma in declarator list are ignored}}
anatofuz
parents:
diff changeset
422 typedef void(*ignored_quals_dummy6)(), __vectorcall ignored_quals6; // expected-warning {{qualifiers after comma in declarator list are ignored}}
anatofuz
parents:
diff changeset
423
anatofuz
parents:
diff changeset
424 namespace {
anatofuz
parents:
diff changeset
425 bool f(int);
anatofuz
parents:
diff changeset
426 template <typename T>
anatofuz
parents:
diff changeset
427 struct A {
anatofuz
parents:
diff changeset
428 constexpr A(T t) {
anatofuz
parents:
diff changeset
429 __assume(f(t)); // expected-warning{{the argument to '__assume' has side effects that will be discarded}}
anatofuz
parents:
diff changeset
430 }
anatofuz
parents:
diff changeset
431 constexpr bool g() { return false; }
anatofuz
parents:
diff changeset
432 };
anatofuz
parents:
diff changeset
433 constexpr A<int> h() {
anatofuz
parents:
diff changeset
434 A<int> b(0); // expected-note {{in instantiation of member function}}
anatofuz
parents:
diff changeset
435 return b;
anatofuz
parents:
diff changeset
436 }
anatofuz
parents:
diff changeset
437 static_assert(h().g() == false, "");
anatofuz
parents:
diff changeset
438 }
anatofuz
parents:
diff changeset
439
anatofuz
parents:
diff changeset
440 namespace {
anatofuz
parents:
diff changeset
441 __declspec(align(16)) struct align_before_key1 {};
anatofuz
parents:
diff changeset
442 __declspec(align(16)) struct align_before_key2 {} align_before_key2_var;
anatofuz
parents:
diff changeset
443 __declspec(align(16)) struct align_before_key3 {} *align_before_key3_var;
anatofuz
parents:
diff changeset
444 static_assert(__alignof(struct align_before_key1) == 16, "");
anatofuz
parents:
diff changeset
445 static_assert(__alignof(struct align_before_key2) == 16, "");
anatofuz
parents:
diff changeset
446 static_assert(__alignof(struct align_before_key3) == 16, "");
anatofuz
parents:
diff changeset
447 }
anatofuz
parents:
diff changeset
448
anatofuz
parents:
diff changeset
449 namespace PR24027 {
anatofuz
parents:
diff changeset
450 struct S {
anatofuz
parents:
diff changeset
451 template <typename T>
anatofuz
parents:
diff changeset
452 S(T);
anatofuz
parents:
diff changeset
453 } f([] {});
anatofuz
parents:
diff changeset
454 }
anatofuz
parents:
diff changeset
455
anatofuz
parents:
diff changeset
456 namespace pr36638 {
anatofuz
parents:
diff changeset
457 // Make sure we accept __unaligned method qualifiers on member function
anatofuz
parents:
diff changeset
458 // pointers.
anatofuz
parents:
diff changeset
459 struct A;
anatofuz
parents:
diff changeset
460 void (A::*mp1)(int) __unaligned;
anatofuz
parents:
diff changeset
461 }
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
462
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
463 namespace enum_class {
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
464 // MSVC allows opaque-enum-declaration syntax anywhere an
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
465 // elaborated-type-specifier can appear.
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
466 // FIXME: Most of these are missing warnings.
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
467 enum E0 *p0; // expected-warning {{Microsoft extension}}
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
468 enum class E1 : int *p1;
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
469 enum E2 : int *p2;
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
470 enum class E3 *p3;
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
471 auto f4() -> enum class E4 { return {}; }
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
472 auto f5() -> enum E5 : int { return {}; } // FIXME: MSVC rejects this and crashes if the body is {}.
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
473 auto f6() -> enum E6 { return {}; } // expected-warning {{Microsoft extension}}
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
474
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
475 // MSVC does not perform disambiguation for a colon that could introduce an
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
476 // enum-base or a bit-field.
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
477 enum E {};
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
478 struct S {
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
479 enum E : int(1); // expected-error {{anonymous bit-field}}
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
480 enum E : int : 1; // OK, bit-field
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
481 enum F : int a = {}; // OK, default member initializer
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
482 // MSVC produces a "C4353 constant 0 as function expression" for this,
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
483 // considering the final {} to be part of the bit-width. We follow P0683R1
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
484 // and treat it as a default member initializer.
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
485 enum E : int : int{}{}; // expected-error {{anonymous bit-field cannot have a default member initializer}}
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
486 };
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
487 }