blob: 1d5811496a76bf279e0c8fa2fb62a442497dfcc8 [file] [log] [blame]
Francois Pichet913b7bf2010-12-20 03:51:03 +00001// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions
Nick Lewycky141ecfe2010-10-12 16:46:35 +00002
3/* Microsoft attribute tests */
4[repeatable][source_annotation_attribute( Parameter|ReturnValue )]
5struct SA_Post{ SA_Post(); int attr; };
6
7[returnvalue:SA_Post( attr=1)]
8int foo1([SA_Post(attr=1)] void *param);
9
10namespace {
11 [returnvalue:SA_Post(attr=1)]
12 int foo2([SA_Post(attr=1)] void *param);
13}
14
15class T {
16 [returnvalue:SA_Post(attr=1)]
17 int foo3([SA_Post(attr=1)] void *param);
18};
19
20extern "C" {
21 [returnvalue:SA_Post(attr=1)]
22 int foo5([SA_Post(attr=1)] void *param);
23}
24
25
Francois Pichet913b7bf2010-12-20 03:51:03 +000026void uuidof_test1()
27{
28 __uuidof(0); // expected-error {{you need to include <guiddef.h> before using the '__uuidof' operator}}
29}
30
31typedef struct _GUID
32{
33 unsigned long Data1;
34 unsigned short Data2;
35 unsigned short Data3;
36 unsigned char Data4[8];
37} GUID;
38
39struct __declspec(uuid(L"00000000-0000-0000-1234-000000000047")) uuid_attr_bad1 { };// expected-error {{'uuid' attribute requires parameter 1 to be a string}}
40struct __declspec(uuid(3)) uuid_attr_bad2 { };// expected-error {{'uuid' attribute requires parameter 1 to be a string}}
41struct __declspec(uuid("0000000-0000-0000-1234-0000500000047")) uuid_attr_bad3 { };// expected-error {{uuid attribute contains a malformed GUID}}
42struct __declspec(uuid("0000000-0000-0000-Z234-000000000047")) uuid_attr_bad4 { };// expected-error {{uuid attribute contains a malformed GUID}}
43struct __declspec(uuid("000000000000-0000-1234-000000000047")) uuid_attr_bad5 { };// expected-error {{uuid attribute contains a malformed GUID}}
44
45
46
47struct __declspec(uuid("000000A0-0000-0000-C000-000000000046"))
48struct_with_uuid { };
49struct struct_without_uuid { };
50
Francois Pichet6915c522010-12-27 01:32:00 +000051struct __declspec(uuid("000000A0-0000-0000-C000-000000000049"))
52struct_with_uuid2;
53
54struct
55struct_with_uuid2 {} ;
Francois Pichet913b7bf2010-12-20 03:51:03 +000056
57int uuid_sema_test()
58{
59 struct_with_uuid var_with_uuid[1];
60 struct_without_uuid var_without_uuid[1];
61
62 __uuidof(struct_with_uuid);
Francois Pichet6915c522010-12-27 01:32:00 +000063 __uuidof(struct_with_uuid2);
Francois Pichet913b7bf2010-12-20 03:51:03 +000064 __uuidof(struct_without_uuid); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
65 __uuidof(struct_with_uuid*);
66 __uuidof(struct_without_uuid*); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
67
68 __uuidof(var_with_uuid);
69 __uuidof(var_without_uuid);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
70 __uuidof(var_with_uuid[1]);
71 __uuidof(var_without_uuid[1]);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
72 __uuidof(&var_with_uuid[1]);
73 __uuidof(&var_without_uuid[1]);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
74
75 __uuidof(0);
76 __uuidof(1);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
77}
Francois Pichet6915c522010-12-27 01:32:00 +000078
79
80template <class T>
81void template_uuid()
82{
83 T expr;
84
85 __uuidof(T);
86 __uuidof(expr);
87}
Francois Pichetdbee3412011-01-18 05:04:39 +000088
89
90
91class CtorCall {
92public:
93 CtorCall& operator=(const CtorCall& that);
94
95 int a;
96};
97
98CtorCall& CtorCall::operator=(const CtorCall& that)
99{
100 if (this != &that) {
101 this->CtorCall::~CtorCall();
102 this->CtorCall::CtorCall(that); // expected-warning {{explicit constructor calls are a Microsoft extension}}
103 }
104 return *this;
105}