blob: 32ed375889a65dbd20c31b44c4066b593e70ddf1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions
/* Microsoft attribute tests */
[repeatable][source_annotation_attribute( Parameter|ReturnValue )]
struct SA_Post{ SA_Post(); int attr; };
[returnvalue:SA_Post( attr=1)]
int foo1([SA_Post(attr=1)] void *param);
namespace {
[returnvalue:SA_Post(attr=1)]
int foo2([SA_Post(attr=1)] void *param);
}
class T {
[returnvalue:SA_Post(attr=1)]
int foo3([SA_Post(attr=1)] void *param);
};
extern "C" {
[returnvalue:SA_Post(attr=1)]
int foo5([SA_Post(attr=1)] void *param);
}
class class_attr {
public:
class_attr([SA_Pre(Null=SA_No,NullTerminated=SA_Yes)] int a)
{
}
};
void uuidof_test1()
{
__uuidof(0); // expected-error {{you need to include <guiddef.h> before using the '__uuidof' operator}}
}
typedef struct _GUID
{
unsigned long Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[8];
} GUID;
struct __declspec(uuid(L"00000000-0000-0000-1234-000000000047")) uuid_attr_bad1 { };// expected-error {{'uuid' attribute requires parameter 1 to be a string}}
struct __declspec(uuid(3)) uuid_attr_bad2 { };// expected-error {{'uuid' attribute requires parameter 1 to be a string}}
struct __declspec(uuid("0000000-0000-0000-1234-0000500000047")) uuid_attr_bad3 { };// expected-error {{uuid attribute contains a malformed GUID}}
struct __declspec(uuid("0000000-0000-0000-Z234-000000000047")) uuid_attr_bad4 { };// expected-error {{uuid attribute contains a malformed GUID}}
struct __declspec(uuid("000000000000-0000-1234-000000000047")) uuid_attr_bad5 { };// expected-error {{uuid attribute contains a malformed GUID}}
struct __declspec(uuid("000000A0-0000-0000-C000-000000000046"))
struct_with_uuid { };
struct struct_without_uuid { };
struct __declspec(uuid("000000A0-0000-0000-C000-000000000049"))
struct_with_uuid2;
struct
struct_with_uuid2 {} ;
int uuid_sema_test()
{
struct_with_uuid var_with_uuid[1];
struct_without_uuid var_without_uuid[1];
__uuidof(struct_with_uuid);
__uuidof(struct_with_uuid2);
__uuidof(struct_without_uuid); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
__uuidof(struct_with_uuid*);
__uuidof(struct_without_uuid*); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
__uuidof(var_with_uuid);
__uuidof(var_without_uuid);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
__uuidof(var_with_uuid[1]);
__uuidof(var_without_uuid[1]);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
__uuidof(&var_with_uuid[1]);
__uuidof(&var_without_uuid[1]);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
__uuidof(0);
__uuidof(1);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
}
template <class T>
void template_uuid()
{
T expr;
__uuidof(T);
__uuidof(expr);
}
template <class T, const GUID* g = &__uuidof(T)>
class COM_CLASS_TEMPLATE { };
typedef COM_CLASS_TEMPLATE<struct_with_uuid, &__uuidof(struct_with_uuid)> COM_TYPE_1;
typedef COM_CLASS_TEMPLATE<struct_with_uuid> COM_TYPE_2;
template <class T, const GUID& g>
class COM_CLASS_TEMPLATE_REF { };
typedef COM_CLASS_TEMPLATE<struct_with_uuid, __uuidof(struct_with_uuid)> COM_TYPE_REF;
class CtorCall {
public:
CtorCall& operator=(const CtorCall& that);
int a;
};
CtorCall& CtorCall::operator=(const CtorCall& that)
{
if (this != &that) {
this->CtorCall::~CtorCall();
this->CtorCall::CtorCall(that); // expected-warning {{explicit constructor calls are a Microsoft extension}}
}
return *this;
}
template <class A>
class C1 {
public:
template <int B>
class Iterator {
};
};
template<class T>
class C2 {
typename C1<T>:: /*template*/ Iterator<0> Mypos; // expected-warning {{use 'template' keyword to treat 'Iterator' as a dependent template name}}
};
template <class T>
void f(){
typename C1<T>:: /*template*/ Iterator<0> Mypos; // expected-warning {{use 'template' keyword to treat 'Iterator' as a dependent template name}}
}
class AAAA { };
template <class T>
void redundant_typename() {
typename T t;// expected-warning {{expected a qualified name after 'typename'}}
typename AAAA a;// expected-warning {{expected a qualified name after 'typename'}}
t = 3;
}
int main() {
redundant_typename<int>();
f<int>();
}
__interface MicrosoftInterface;
__interface MicrosoftInterface {
virtual void foo1() = 0;
virtual void foo2() = 0;
};
__int64 x7 = __int64(0);
|