1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 %s -triple i386-mingw32 -std=c++11 -fsyntax-only -Wno-unused-getter-return-value -Wno-unused-value -Wmicrosoft -verify -fms-extensions -fms-compatibility -fdelayed-template-parsing
2f4a2713aSLionel Sambuc
3f4a2713aSLionel Sambuc /* Microsoft attribute tests */
4f4a2713aSLionel Sambuc [repeatable][source_annotation_attribute( Parameter|ReturnValue )]
5f4a2713aSLionel Sambuc struct SA_Post{ SA_Post(); int attr; };
6f4a2713aSLionel Sambuc
7f4a2713aSLionel Sambuc [returnvalue:SA_Post( attr=1)]
8f4a2713aSLionel Sambuc int foo1([SA_Post(attr=1)] void *param);
9f4a2713aSLionel Sambuc
10f4a2713aSLionel Sambuc namespace {
11f4a2713aSLionel Sambuc [returnvalue:SA_Post(attr=1)]
12f4a2713aSLionel Sambuc int foo2([SA_Post(attr=1)] void *param);
13f4a2713aSLionel Sambuc }
14f4a2713aSLionel Sambuc
15f4a2713aSLionel Sambuc class T {
16f4a2713aSLionel Sambuc [returnvalue:SA_Post(attr=1)]
17f4a2713aSLionel Sambuc int foo3([SA_Post(attr=1)] void *param);
18f4a2713aSLionel Sambuc };
19f4a2713aSLionel Sambuc
20f4a2713aSLionel Sambuc extern "C" {
21f4a2713aSLionel Sambuc [returnvalue:SA_Post(attr=1)]
22f4a2713aSLionel Sambuc int foo5([SA_Post(attr=1)] void *param);
23f4a2713aSLionel Sambuc }
24f4a2713aSLionel Sambuc
25f4a2713aSLionel Sambuc class class_attr {
26f4a2713aSLionel Sambuc public:
27f4a2713aSLionel Sambuc class_attr([SA_Pre(Null=SA_No,NullTerminated=SA_Yes)] int a)
28f4a2713aSLionel Sambuc {
29f4a2713aSLionel Sambuc }
30f4a2713aSLionel Sambuc };
31f4a2713aSLionel Sambuc
32f4a2713aSLionel Sambuc
33f4a2713aSLionel Sambuc
uuidof_test1()34f4a2713aSLionel Sambuc void uuidof_test1()
35f4a2713aSLionel Sambuc {
36f4a2713aSLionel Sambuc __uuidof(0); // expected-error {{you need to include <guiddef.h> before using the '__uuidof' operator}}
37f4a2713aSLionel Sambuc }
38f4a2713aSLionel Sambuc
39f4a2713aSLionel Sambuc typedef struct _GUID
40f4a2713aSLionel Sambuc {
41f4a2713aSLionel Sambuc unsigned long Data1;
42f4a2713aSLionel Sambuc unsigned short Data2;
43f4a2713aSLionel Sambuc unsigned short Data3;
44f4a2713aSLionel Sambuc unsigned char Data4[8];
45f4a2713aSLionel Sambuc } GUID;
46f4a2713aSLionel Sambuc
47f4a2713aSLionel Sambuc struct __declspec(uuid(L"00000000-0000-0000-1234-000000000047")) uuid_attr_bad1 { };// expected-error {{'uuid' attribute requires a string}}
48f4a2713aSLionel Sambuc struct __declspec(uuid(3)) uuid_attr_bad2 { };// expected-error {{'uuid' attribute requires a string}}
49f4a2713aSLionel Sambuc struct __declspec(uuid("0000000-0000-0000-1234-0000500000047")) uuid_attr_bad3 { };// expected-error {{uuid attribute contains a malformed GUID}}
50f4a2713aSLionel Sambuc struct __declspec(uuid("0000000-0000-0000-Z234-000000000047")) uuid_attr_bad4 { };// expected-error {{uuid attribute contains a malformed GUID}}
51f4a2713aSLionel Sambuc struct __declspec(uuid("000000000000-0000-1234-000000000047")) uuid_attr_bad5 { };// expected-error {{uuid attribute contains a malformed GUID}}
52f4a2713aSLionel Sambuc
53*0a6a1f1dSLionel Sambuc __declspec(uuid("000000A0-0000-0000-C000-000000000046")) int i; // expected-warning {{'uuid' attribute only applies to classes}}
54f4a2713aSLionel Sambuc
55f4a2713aSLionel Sambuc struct __declspec(uuid("000000A0-0000-0000-C000-000000000046"))
56f4a2713aSLionel Sambuc struct_with_uuid { };
57f4a2713aSLionel Sambuc struct struct_without_uuid { };
58f4a2713aSLionel Sambuc
59f4a2713aSLionel Sambuc struct __declspec(uuid("000000A0-0000-0000-C000-000000000049"))
60f4a2713aSLionel Sambuc struct_with_uuid2;
61f4a2713aSLionel Sambuc
62f4a2713aSLionel Sambuc struct
63f4a2713aSLionel Sambuc struct_with_uuid2 {} ;
64f4a2713aSLionel Sambuc
uuid_sema_test()65f4a2713aSLionel Sambuc int uuid_sema_test()
66f4a2713aSLionel Sambuc {
67f4a2713aSLionel Sambuc struct_with_uuid var_with_uuid[1];
68f4a2713aSLionel Sambuc struct_without_uuid var_without_uuid[1];
69f4a2713aSLionel Sambuc
70f4a2713aSLionel Sambuc __uuidof(struct_with_uuid);
71f4a2713aSLionel Sambuc __uuidof(struct_with_uuid2);
72f4a2713aSLionel Sambuc __uuidof(struct_without_uuid); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
73f4a2713aSLionel Sambuc __uuidof(struct_with_uuid*);
74f4a2713aSLionel Sambuc __uuidof(struct_without_uuid*); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
75f4a2713aSLionel Sambuc __uuidof(struct_with_uuid[1]);
76f4a2713aSLionel Sambuc __uuidof(struct_with_uuid*[1]); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
77f4a2713aSLionel Sambuc __uuidof(const struct_with_uuid[1][1]);
78f4a2713aSLionel Sambuc __uuidof(const struct_with_uuid*[1][1]); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
79f4a2713aSLionel Sambuc
80f4a2713aSLionel Sambuc __uuidof(var_with_uuid);
81f4a2713aSLionel Sambuc __uuidof(var_without_uuid);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
82f4a2713aSLionel Sambuc __uuidof(var_with_uuid[1]);
83f4a2713aSLionel Sambuc __uuidof(var_without_uuid[1]);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
84f4a2713aSLionel Sambuc __uuidof(&var_with_uuid[1]);
85f4a2713aSLionel Sambuc __uuidof(&var_without_uuid[1]);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
86f4a2713aSLionel Sambuc
87f4a2713aSLionel Sambuc __uuidof(0);
88f4a2713aSLionel Sambuc __uuidof(1);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
89f4a2713aSLionel Sambuc }
90f4a2713aSLionel Sambuc
91f4a2713aSLionel Sambuc
92f4a2713aSLionel Sambuc template <class T>
template_uuid()93f4a2713aSLionel Sambuc void template_uuid()
94f4a2713aSLionel Sambuc {
95f4a2713aSLionel Sambuc T expr;
96f4a2713aSLionel Sambuc
97f4a2713aSLionel Sambuc __uuidof(T);
98f4a2713aSLionel Sambuc __uuidof(expr);
99f4a2713aSLionel Sambuc }
100f4a2713aSLionel Sambuc
101f4a2713aSLionel Sambuc
102f4a2713aSLionel Sambuc template <class T, const GUID* g = &__uuidof(T)> // expected-note {{template parameter is declared here}}
103f4a2713aSLionel Sambuc class COM_CLASS_TEMPLATE { };
104f4a2713aSLionel Sambuc
105f4a2713aSLionel Sambuc 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}}
106f4a2713aSLionel Sambuc typedef COM_CLASS_TEMPLATE<struct_with_uuid> COM_TYPE_2;
107f4a2713aSLionel Sambuc
108f4a2713aSLionel Sambuc template <class T, const GUID& g>
109f4a2713aSLionel Sambuc class COM_CLASS_TEMPLATE_REF { };
110f4a2713aSLionel Sambuc typedef COM_CLASS_TEMPLATE_REF<struct_with_uuid, __uuidof(struct_with_uuid)> COM_TYPE_REF;
111f4a2713aSLionel Sambuc
112f4a2713aSLionel Sambuc struct late_defined_uuid;
113f4a2713aSLionel Sambuc template<typename T>
test_late_defined_uuid()114f4a2713aSLionel Sambuc void test_late_defined_uuid() {
115f4a2713aSLionel Sambuc __uuidof(late_defined_uuid);
116f4a2713aSLionel Sambuc }
117f4a2713aSLionel Sambuc struct __declspec(uuid("000000A0-0000-0000-C000-000000000049")) late_defined_uuid;
118f4a2713aSLionel Sambuc
119f4a2713aSLionel Sambuc COM_CLASS_TEMPLATE_REF<int, __uuidof(struct_with_uuid)> good_template_arg;
120f4a2713aSLionel Sambuc
121f4a2713aSLionel Sambuc COM_CLASS_TEMPLATE<int, __uuidof(struct_with_uuid)> bad_template_arg; // expected-error {{non-type template argument of type 'const _GUID' is not a constant expression}}
122f4a2713aSLionel Sambuc
123f4a2713aSLionel Sambuc namespace PR16911 {
124f4a2713aSLionel Sambuc struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid;
125f4a2713aSLionel Sambuc struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid2;
126f4a2713aSLionel Sambuc
127f4a2713aSLionel Sambuc template <typename T, typename T2>
128f4a2713aSLionel Sambuc struct thing {
129f4a2713aSLionel Sambuc };
130f4a2713aSLionel Sambuc
131f4a2713aSLionel Sambuc struct empty {};
132f4a2713aSLionel Sambuc struct inher : public thing<empty, uuid2> {};
133f4a2713aSLionel Sambuc
134f4a2713aSLionel Sambuc struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid;
135f4a2713aSLionel Sambuc const struct _GUID *w = &__uuidof(inher); // expected-error{{cannot call operator __uuidof on a type with no GUID}}
136f4a2713aSLionel Sambuc const struct _GUID *x = &__uuidof(thing<uuid, inher>);
137f4a2713aSLionel Sambuc const struct _GUID *y = &__uuidof(thing<uuid2, uuid>); // expected-error{{cannot call operator __uuidof on a type with multiple GUIDs}}
138f4a2713aSLionel Sambuc thing<uuid2, uuid> thing_obj = thing<uuid2, uuid>();
139f4a2713aSLionel Sambuc const struct _GUID *z = &__uuidof(thing_obj); // expected-error{{cannot call operator __uuidof on a type with multiple GUIDs}}
140f4a2713aSLionel Sambuc }
141f4a2713aSLionel Sambuc
142f4a2713aSLionel Sambuc class CtorCall {
143f4a2713aSLionel Sambuc public:
144f4a2713aSLionel Sambuc CtorCall& operator=(const CtorCall& that);
145f4a2713aSLionel Sambuc
146f4a2713aSLionel Sambuc int a;
147f4a2713aSLionel Sambuc };
148f4a2713aSLionel Sambuc
operator =(const CtorCall & that)149f4a2713aSLionel Sambuc CtorCall& CtorCall::operator=(const CtorCall& that)
150f4a2713aSLionel Sambuc {
151f4a2713aSLionel Sambuc if (this != &that) {
152f4a2713aSLionel Sambuc this->CtorCall::~CtorCall();
153f4a2713aSLionel Sambuc this->CtorCall::CtorCall(that); // expected-warning {{explicit constructor calls are a Microsoft extension}}
154f4a2713aSLionel Sambuc }
155f4a2713aSLionel Sambuc return *this;
156f4a2713aSLionel Sambuc }
157f4a2713aSLionel Sambuc
158f4a2713aSLionel Sambuc template <class A>
159f4a2713aSLionel Sambuc class C1 {
160f4a2713aSLionel Sambuc public:
161f4a2713aSLionel Sambuc template <int B>
162f4a2713aSLionel Sambuc class Iterator {
163f4a2713aSLionel Sambuc };
164f4a2713aSLionel Sambuc };
165f4a2713aSLionel Sambuc
166f4a2713aSLionel Sambuc template<class T>
167f4a2713aSLionel Sambuc class C2 {
168f4a2713aSLionel Sambuc typename C1<T>:: /*template*/ Iterator<0> Mypos; // expected-warning {{use 'template' keyword to treat 'Iterator' as a dependent template name}}
169f4a2713aSLionel Sambuc };
170f4a2713aSLionel Sambuc
171f4a2713aSLionel Sambuc template <class T>
missing_template_keyword()172f4a2713aSLionel Sambuc void missing_template_keyword(){
173f4a2713aSLionel Sambuc typename C1<T>:: /*template*/ Iterator<0> Mypos; // expected-warning {{use 'template' keyword to treat 'Iterator' as a dependent template name}}
174f4a2713aSLionel Sambuc }
175f4a2713aSLionel Sambuc
176f4a2713aSLionel Sambuc
177f4a2713aSLionel Sambuc
178f4a2713aSLionel Sambuc class AAAA {
179f4a2713aSLionel Sambuc typedef int D;
180f4a2713aSLionel Sambuc };
181f4a2713aSLionel Sambuc
182f4a2713aSLionel Sambuc template <typename T>
183f4a2713aSLionel Sambuc class SimpleTemplate {};
184f4a2713aSLionel Sambuc
185f4a2713aSLionel Sambuc template <class T>
redundant_typename()186f4a2713aSLionel Sambuc void redundant_typename() {
187f4a2713aSLionel Sambuc typename T t;// expected-warning {{expected a qualified name after 'typename'}}
188f4a2713aSLionel Sambuc typename AAAA a;// expected-warning {{expected a qualified name after 'typename'}}
189f4a2713aSLionel Sambuc
190f4a2713aSLionel Sambuc t = 3;
191f4a2713aSLionel Sambuc
192f4a2713aSLionel Sambuc typedef typename T* pointerT;// expected-warning {{expected a qualified name after 'typename'}}
193f4a2713aSLionel Sambuc typedef typename SimpleTemplate<int> templateT;// expected-warning {{expected a qualified name after 'typename'}}
194f4a2713aSLionel Sambuc
195f4a2713aSLionel Sambuc pointerT pT = &t;
196f4a2713aSLionel Sambuc *pT = 4;
197f4a2713aSLionel Sambuc
198f4a2713aSLionel Sambuc int var;
199f4a2713aSLionel Sambuc int k = typename var;// expected-error {{expected a qualified name after 'typename'}}
200f4a2713aSLionel Sambuc }
201f4a2713aSLionel Sambuc
202f4a2713aSLionel Sambuc template <typename T>
203f4a2713aSLionel Sambuc struct TypenameWrongPlace {
204f4a2713aSLionel Sambuc typename typedef T::D D;// expected-warning {{expected a qualified name after 'typename'}}
205f4a2713aSLionel Sambuc };
206f4a2713aSLionel Sambuc
207f4a2713aSLionel Sambuc extern TypenameWrongPlace<AAAA> PR16925;
208f4a2713aSLionel Sambuc
209f4a2713aSLionel Sambuc __interface MicrosoftInterface;
210f4a2713aSLionel Sambuc __interface MicrosoftInterface {
211*0a6a1f1dSLionel Sambuc void foo1() = 0; // expected-note {{overridden virtual function is here}}
212f4a2713aSLionel Sambuc virtual void foo2() = 0;
213f4a2713aSLionel Sambuc };
214f4a2713aSLionel Sambuc
215f4a2713aSLionel Sambuc __interface MicrosoftDerivedInterface : public MicrosoftInterface {
216*0a6a1f1dSLionel Sambuc void foo1(); // expected-warning {{'foo1' overrides a member function but is not marked 'override'}}
217f4a2713aSLionel Sambuc void foo2() override;
218f4a2713aSLionel Sambuc void foo3();
219f4a2713aSLionel Sambuc };
220f4a2713aSLionel Sambuc
221f4a2713aSLionel Sambuc void interface_test() {
222f4a2713aSLionel Sambuc MicrosoftInterface* a;
223f4a2713aSLionel Sambuc a->foo1();
224f4a2713aSLionel Sambuc MicrosoftDerivedInterface* b;
225f4a2713aSLionel Sambuc b->foo2();
226f4a2713aSLionel Sambuc }
227f4a2713aSLionel Sambuc
228f4a2713aSLionel Sambuc __int64 x7 = __int64(0);
229*0a6a1f1dSLionel Sambuc _int64 x8 = _int64(0);
230*0a6a1f1dSLionel Sambuc static_assert(sizeof(_int64) == 8, "");
231*0a6a1f1dSLionel Sambuc static_assert(sizeof(_int32) == 4, "");
232*0a6a1f1dSLionel Sambuc static_assert(sizeof(_int16) == 2, "");
233*0a6a1f1dSLionel Sambuc static_assert(sizeof(_int8) == 1, "");
234f4a2713aSLionel Sambuc
235f4a2713aSLionel Sambuc int __identifier(generic) = 3;
236*0a6a1f1dSLionel Sambuc int __identifier(int) = 4;
237*0a6a1f1dSLionel Sambuc struct __identifier(class) { __identifier(class) *__identifier(for); };
238*0a6a1f1dSLionel Sambuc __identifier(class) __identifier(struct) = { &__identifier(struct) };
239*0a6a1f1dSLionel Sambuc
240*0a6a1f1dSLionel Sambuc int __identifier for; // expected-error {{missing '(' after '__identifier'}}
241*0a6a1f1dSLionel Sambuc int __identifier(else} = __identifier(for); // expected-error {{missing ')' after identifier}} expected-note {{to match this '('}}
242*0a6a1f1dSLionel Sambuc #define identifier_weird(x) __identifier(x
243*0a6a1f1dSLionel Sambuc int k = identifier_weird(if)); // expected-error {{use of undeclared identifier 'if'}}
244*0a6a1f1dSLionel Sambuc
245*0a6a1f1dSLionel Sambuc // This is a bit weird, but the alternative tokens aren't keywords, and this
246*0a6a1f1dSLionel Sambuc // behavior matches MSVC. FIXME: Consider supporting this anyway.
247*0a6a1f1dSLionel Sambuc extern int __identifier(and) r; // expected-error {{cannot convert '&&' token to an identifier}}
248*0a6a1f1dSLionel Sambuc
249*0a6a1f1dSLionel Sambuc void f() {
250*0a6a1f1dSLionel Sambuc __identifier(() // expected-error {{cannot convert '(' token to an identifier}}
251*0a6a1f1dSLionel Sambuc __identifier(void) // expected-error {{use of undeclared identifier 'void'}}
252*0a6a1f1dSLionel Sambuc __identifier()) // expected-error {{cannot convert ')' token to an identifier}}
253*0a6a1f1dSLionel Sambuc // FIXME: We should pick a friendlier display name for this token kind.
254*0a6a1f1dSLionel Sambuc __identifier(1) // expected-error {{cannot convert <numeric_constant> token to an identifier}}
255*0a6a1f1dSLionel Sambuc __identifier(+) // expected-error {{cannot convert '+' token to an identifier}}
256*0a6a1f1dSLionel Sambuc __identifier("foo") // expected-error {{cannot convert <string_literal> token to an identifier}}
257*0a6a1f1dSLionel Sambuc __identifier(;) // expected-error {{cannot convert ';' token to an identifier}}
258*0a6a1f1dSLionel Sambuc }
259f4a2713aSLionel Sambuc
260f4a2713aSLionel Sambuc class inline_definition_pure_spec {
261f4a2713aSLionel Sambuc virtual int f() = 0 { return 0; }// expected-warning {{function definition with pure-specifier is a Microsoft extension}}
262f4a2713aSLionel Sambuc virtual int f2() = 0;
263f4a2713aSLionel Sambuc };
264f4a2713aSLionel Sambuc
265f4a2713aSLionel Sambuc struct pure_virtual_dtor {
266f4a2713aSLionel Sambuc virtual ~pure_virtual_dtor() = 0;
267f4a2713aSLionel Sambuc };
268f4a2713aSLionel Sambuc pure_virtual_dtor::~pure_virtual_dtor() { }
269f4a2713aSLionel Sambuc
270f4a2713aSLionel Sambuc struct pure_virtual_dtor_inline {
271f4a2713aSLionel Sambuc virtual ~pure_virtual_dtor_inline() = 0 { }// expected-warning {{function definition with pure-specifier is a Microsoft extension}}
272f4a2713aSLionel Sambuc };
273f4a2713aSLionel Sambuc
274f4a2713aSLionel Sambuc
275f4a2713aSLionel Sambuc int main () {
276f4a2713aSLionel Sambuc // Necessary to force instantiation in -fdelayed-template-parsing mode.
277f4a2713aSLionel Sambuc test_late_defined_uuid<int>();
278f4a2713aSLionel Sambuc redundant_typename<int>();
279f4a2713aSLionel Sambuc missing_template_keyword<int>();
280f4a2713aSLionel Sambuc }
281f4a2713aSLionel Sambuc
282f4a2713aSLionel Sambuc namespace access_protected_PTM {
283f4a2713aSLionel Sambuc class A {
284f4a2713aSLionel Sambuc protected:
285f4a2713aSLionel Sambuc void f(); // expected-note {{must name member using the type of the current context 'access_protected_PTM::B'}}
286f4a2713aSLionel Sambuc };
287f4a2713aSLionel Sambuc
288f4a2713aSLionel Sambuc class B : public A{
289f4a2713aSLionel Sambuc public:
290f4a2713aSLionel Sambuc void test_access();
291f4a2713aSLionel Sambuc static void test_access_static();
292f4a2713aSLionel Sambuc };
293f4a2713aSLionel Sambuc
294f4a2713aSLionel Sambuc void B::test_access() {
295f4a2713aSLionel Sambuc &A::f; // expected-error {{'f' is a protected member of 'access_protected_PTM::A'}}
296f4a2713aSLionel Sambuc }
297f4a2713aSLionel Sambuc
298f4a2713aSLionel Sambuc void B::test_access_static() {
299f4a2713aSLionel Sambuc &A::f;
300f4a2713aSLionel Sambuc }
301f4a2713aSLionel Sambuc }
302f4a2713aSLionel Sambuc
303f4a2713aSLionel Sambuc namespace Inheritance {
304f4a2713aSLionel Sambuc class __single_inheritance A;
305f4a2713aSLionel Sambuc class __multiple_inheritance B;
306f4a2713aSLionel Sambuc class __virtual_inheritance C;
307f4a2713aSLionel Sambuc }
308f4a2713aSLionel Sambuc
309f4a2713aSLionel Sambuc struct StructWithProperty {
310f4a2713aSLionel Sambuc __declspec(property) int V0; // expected-error {{expected '(' after 'property'}}
311f4a2713aSLionel Sambuc __declspec(property()) int V1; // expected-error {{property does not specify a getter or a putter}}
312f4a2713aSLionel Sambuc __declspec(property(set)) int V2; // expected-error {{putter for property must be specified as 'put', not 'set'}} expected-error {{expected '=' after 'set'}}
313f4a2713aSLionel Sambuc __declspec(property(ptu)) int V3; // expected-error {{missing 'get=' or 'put='}}
314f4a2713aSLionel Sambuc __declspec(property(ptu=PutV)) int V4; // expected-error {{expected 'get' or 'put' in property declaration}}
315f4a2713aSLionel Sambuc __declspec(property(get)) int V5; // expected-error {{expected '=' after 'get'}}
316f4a2713aSLionel Sambuc __declspec(property(get&)) int V6; // expected-error {{expected '=' after 'get'}}
317f4a2713aSLionel Sambuc __declspec(property(get=)) int V7; // expected-error {{expected name of accessor method}}
318f4a2713aSLionel Sambuc __declspec(property(get=GetV)) int V8; // no-warning
319f4a2713aSLionel Sambuc __declspec(property(get=GetV=)) int V9; // expected-error {{expected ',' or ')' at end of property accessor list}}
320f4a2713aSLionel Sambuc __declspec(property(get=GetV,)) int V10; // expected-error {{expected 'get' or 'put' in property declaration}}
321f4a2713aSLionel Sambuc __declspec(property(get=GetV,put=SetV)) int V11; // no-warning
322f4a2713aSLionel Sambuc __declspec(property(get=GetV,put=SetV,get=GetV)) int V12; // expected-error {{property declaration specifies 'get' accessor twice}}
323*0a6a1f1dSLionel Sambuc __declspec(property(get=GetV)) int V13 = 3; // expected-error {{property declaration cannot have an in-class initializer}}
324f4a2713aSLionel Sambuc
325f4a2713aSLionel Sambuc int GetV() { return 123; }
326f4a2713aSLionel Sambuc void SetV(int v) {}
327f4a2713aSLionel Sambuc };
328f4a2713aSLionel Sambuc void TestProperty() {
329f4a2713aSLionel Sambuc StructWithProperty sp;
330f4a2713aSLionel Sambuc sp.V8;
331f4a2713aSLionel Sambuc sp.V8 = 0; // expected-error {{no setter defined for property 'V8'}}
332f4a2713aSLionel Sambuc int i = sp.V11;
333f4a2713aSLionel Sambuc sp.V11 = i++;
334f4a2713aSLionel Sambuc sp.V11 += 8;
335f4a2713aSLionel Sambuc sp.V11++;
336f4a2713aSLionel Sambuc ++sp.V11;
337f4a2713aSLionel Sambuc }
338*0a6a1f1dSLionel Sambuc
339*0a6a1f1dSLionel Sambuc //expected-warning@+1 {{C++ operator 'and' (aka '&&') used as a macro name}}
340*0a6a1f1dSLionel Sambuc #define and foo
341*0a6a1f1dSLionel Sambuc
342*0a6a1f1dSLionel Sambuc struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) __declspec(novtable) IUnknown {}; // expected-warning{{__declspec attribute 'novtable' is not supported}}
343*0a6a1f1dSLionel Sambuc
344*0a6a1f1dSLionel Sambuc typedef bool (__stdcall __stdcall *blarg)(int);
345*0a6a1f1dSLionel Sambuc
346*0a6a1f1dSLionel Sambuc void local_callconv() {
347*0a6a1f1dSLionel Sambuc bool (__stdcall *p)(int);
348*0a6a1f1dSLionel Sambuc }
349*0a6a1f1dSLionel Sambuc
350*0a6a1f1dSLionel Sambuc struct S7 {
351*0a6a1f1dSLionel Sambuc int foo() { return 12; }
352*0a6a1f1dSLionel Sambuc __declspec(property(get=foo) deprecated) int t; // expected-note {{'t' has been explicitly marked deprecated here}}
353*0a6a1f1dSLionel Sambuc };
354*0a6a1f1dSLionel Sambuc
355*0a6a1f1dSLionel Sambuc // Technically, this is legal (though it does nothing)
356*0a6a1f1dSLionel Sambuc __declspec() void quux( void ) {
357*0a6a1f1dSLionel Sambuc struct S7 s;
358*0a6a1f1dSLionel Sambuc int i = s.t; // expected-warning {{'t' is deprecated}}
359*0a6a1f1dSLionel Sambuc }
360*0a6a1f1dSLionel Sambuc
361*0a6a1f1dSLionel Sambuc void *_alloca(int);
362*0a6a1f1dSLionel Sambuc
363*0a6a1f1dSLionel Sambuc void foo(void) {
364*0a6a1f1dSLionel Sambuc __declspec(align(16)) int *buffer = (int *)_alloca(9);
365*0a6a1f1dSLionel Sambuc }
366*0a6a1f1dSLionel Sambuc
367*0a6a1f1dSLionel Sambuc template <int *>
368*0a6a1f1dSLionel Sambuc struct NullptrArg {};
369*0a6a1f1dSLionel Sambuc NullptrArg<nullptr> a;
370*0a6a1f1dSLionel Sambuc
371*0a6a1f1dSLionel Sambuc // Ignored type qualifiers after comma in declarator lists
372*0a6a1f1dSLionel Sambuc 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}}
373*0a6a1f1dSLionel Sambuc typedef void(*ignored_quals_dummy2)(), __fastcall ignored_quals2; // expected-warning {{qualifiers after comma in declarator list are ignored}}
374*0a6a1f1dSLionel Sambuc typedef void(*ignored_quals_dummy3)(), __stdcall ignored_quals3; // expected-warning {{qualifiers after comma in declarator list are ignored}}
375*0a6a1f1dSLionel Sambuc typedef void(*ignored_quals_dummy4)(), __thiscall ignored_quals4; // expected-warning {{qualifiers after comma in declarator list are ignored}}
376*0a6a1f1dSLionel Sambuc typedef void(*ignored_quals_dummy5)(), __cdecl ignored_quals5; // expected-warning {{qualifiers after comma in declarator list are ignored}}
377*0a6a1f1dSLionel Sambuc typedef void(*ignored_quals_dummy6)(), __vectorcall ignored_quals6; // expected-warning {{qualifiers after comma in declarator list are ignored}}
378