Francois Pichet | a39371c | 2012-04-17 12:35:05 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions -fms-compatibility -fdelayed-template-parsing |
Nick Lewycky | 8d3a178 | 2010-10-12 16:46:35 +0000 | [diff] [blame] | 2 | |
| 3 | /* Microsoft attribute tests */ |
| 4 | [repeatable][source_annotation_attribute( Parameter|ReturnValue )] |
| 5 | struct SA_Post{ SA_Post(); int attr; }; |
| 6 | |
Aaron Ballman | 3bf758c | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 7 | [returnvalue:SA_Post( attr=1)] |
Nick Lewycky | 8d3a178 | 2010-10-12 16:46:35 +0000 | [diff] [blame] | 8 | int foo1([SA_Post(attr=1)] void *param); |
| 9 | |
| 10 | namespace { |
Aaron Ballman | 3bf758c | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 11 | [returnvalue:SA_Post(attr=1)] |
Nick Lewycky | 8d3a178 | 2010-10-12 16:46:35 +0000 | [diff] [blame] | 12 | int foo2([SA_Post(attr=1)] void *param); |
| 13 | } |
| 14 | |
| 15 | class T { |
Aaron Ballman | 3bf758c | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 16 | [returnvalue:SA_Post(attr=1)] |
Nick Lewycky | 8d3a178 | 2010-10-12 16:46:35 +0000 | [diff] [blame] | 17 | int foo3([SA_Post(attr=1)] void *param); |
| 18 | }; |
| 19 | |
| 20 | extern "C" { |
Aaron Ballman | 3bf758c | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 21 | [returnvalue:SA_Post(attr=1)] |
Nick Lewycky | 8d3a178 | 2010-10-12 16:46:35 +0000 | [diff] [blame] | 22 | int foo5([SA_Post(attr=1)] void *param); |
| 23 | } |
| 24 | |
Francois Pichet | 79f3a87 | 2011-01-31 04:54:32 +0000 | [diff] [blame] | 25 | class class_attr { |
| 26 | public: |
| 27 | class_attr([SA_Pre(Null=SA_No,NullTerminated=SA_Yes)] int a) |
| 28 | { |
| 29 | } |
| 30 | }; |
| 31 | |
| 32 | |
Nick Lewycky | 8d3a178 | 2010-10-12 16:46:35 +0000 | [diff] [blame] | 33 | |
Francois Pichet | 9dddd40 | 2010-12-20 03:51:03 +0000 | [diff] [blame] | 34 | void uuidof_test1() |
Aaron Ballman | 3bf758c | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 35 | { |
Francois Pichet | 9dddd40 | 2010-12-20 03:51:03 +0000 | [diff] [blame] | 36 | __uuidof(0); // expected-error {{you need to include <guiddef.h> before using the '__uuidof' operator}} |
| 37 | } |
| 38 | |
| 39 | typedef struct _GUID |
| 40 | { |
| 41 | unsigned long Data1; |
| 42 | unsigned short Data2; |
| 43 | unsigned short Data3; |
| 44 | unsigned char Data4[8]; |
| 45 | } GUID; |
| 46 | |
Aaron Ballman | 3bf758c | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 47 | struct __declspec(uuid(L"00000000-0000-0000-1234-000000000047")) uuid_attr_bad1 { };// expected-error {{'uuid' attribute requires a string}} |
| 48 | struct __declspec(uuid(3)) uuid_attr_bad2 { };// expected-error {{'uuid' attribute requires a string}} |
Francois Pichet | 9dddd40 | 2010-12-20 03:51:03 +0000 | [diff] [blame] | 49 | struct __declspec(uuid("0000000-0000-0000-1234-0000500000047")) uuid_attr_bad3 { };// expected-error {{uuid attribute contains a malformed GUID}} |
| 50 | struct __declspec(uuid("0000000-0000-0000-Z234-000000000047")) uuid_attr_bad4 { };// expected-error {{uuid attribute contains a malformed GUID}} |
| 51 | struct __declspec(uuid("000000000000-0000-1234-000000000047")) uuid_attr_bad5 { };// expected-error {{uuid attribute contains a malformed GUID}} |
| 52 | |
Aaron Ballman | 60e705e | 2013-11-24 20:58:02 +0000 | [diff] [blame] | 53 | __declspec(uuid("000000A0-0000-0000-C000-000000000046")) int i; // expected-warning {{'uuid' attribute only applies to classes}} |
Francois Pichet | 9dddd40 | 2010-12-20 03:51:03 +0000 | [diff] [blame] | 54 | |
| 55 | struct __declspec(uuid("000000A0-0000-0000-C000-000000000046")) |
| 56 | struct_with_uuid { }; |
| 57 | struct struct_without_uuid { }; |
| 58 | |
Francois Pichet | b757765 | 2010-12-27 01:32:00 +0000 | [diff] [blame] | 59 | struct __declspec(uuid("000000A0-0000-0000-C000-000000000049")) |
| 60 | struct_with_uuid2; |
| 61 | |
Aaron Ballman | 3bf758c | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 62 | struct |
Francois Pichet | b757765 | 2010-12-27 01:32:00 +0000 | [diff] [blame] | 63 | struct_with_uuid2 {} ; |
Francois Pichet | 9dddd40 | 2010-12-20 03:51:03 +0000 | [diff] [blame] | 64 | |
| 65 | int uuid_sema_test() |
| 66 | { |
| 67 | struct_with_uuid var_with_uuid[1]; |
| 68 | struct_without_uuid var_without_uuid[1]; |
| 69 | |
| 70 | __uuidof(struct_with_uuid); |
Francois Pichet | b757765 | 2010-12-27 01:32:00 +0000 | [diff] [blame] | 71 | __uuidof(struct_with_uuid2); |
Francois Pichet | 9dddd40 | 2010-12-20 03:51:03 +0000 | [diff] [blame] | 72 | __uuidof(struct_without_uuid); // expected-error {{cannot call operator __uuidof on a type with no GUID}} |
| 73 | __uuidof(struct_with_uuid*); |
| 74 | __uuidof(struct_without_uuid*); // expected-error {{cannot call operator __uuidof on a type with no GUID}} |
David Majnemer | 68c880b | 2013-09-27 07:57:34 +0000 | [diff] [blame] | 75 | __uuidof(struct_with_uuid[1]); |
| 76 | __uuidof(struct_with_uuid*[1]); // expected-error {{cannot call operator __uuidof on a type with no GUID}} |
| 77 | __uuidof(const struct_with_uuid[1][1]); |
| 78 | __uuidof(const struct_with_uuid*[1][1]); // expected-error {{cannot call operator __uuidof on a type with no GUID}} |
Francois Pichet | 9dddd40 | 2010-12-20 03:51:03 +0000 | [diff] [blame] | 79 | |
| 80 | __uuidof(var_with_uuid); |
| 81 | __uuidof(var_without_uuid);// expected-error {{cannot call operator __uuidof on a type with no GUID}} |
| 82 | __uuidof(var_with_uuid[1]); |
| 83 | __uuidof(var_without_uuid[1]);// expected-error {{cannot call operator __uuidof on a type with no GUID}} |
| 84 | __uuidof(&var_with_uuid[1]); |
| 85 | __uuidof(&var_without_uuid[1]);// expected-error {{cannot call operator __uuidof on a type with no GUID}} |
| 86 | |
| 87 | __uuidof(0); |
| 88 | __uuidof(1);// expected-error {{cannot call operator __uuidof on a type with no GUID}} |
| 89 | } |
Francois Pichet | b757765 | 2010-12-27 01:32:00 +0000 | [diff] [blame] | 90 | |
| 91 | |
| 92 | template <class T> |
| 93 | void template_uuid() |
| 94 | { |
| 95 | T expr; |
Aaron Ballman | 3bf758c | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 96 | |
Francois Pichet | b757765 | 2010-12-27 01:32:00 +0000 | [diff] [blame] | 97 | __uuidof(T); |
| 98 | __uuidof(expr); |
| 99 | } |
Francois Pichet | 6422579 | 2011-01-18 05:04:39 +0000 | [diff] [blame] | 100 | |
| 101 | |
David Majnemer | 61c39a1 | 2013-08-23 05:39:39 +0000 | [diff] [blame] | 102 | template <class T, const GUID* g = &__uuidof(T)> // expected-note {{template parameter is declared here}} |
Francois Pichet | a1c1352 | 2011-04-28 04:39:50 +0000 | [diff] [blame] | 103 | class COM_CLASS_TEMPLATE { }; |
| 104 | |
David Majnemer | 61c39a1 | 2013-08-23 05:39:39 +0000 | [diff] [blame] | 105 | 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}} |
Francois Pichet | a1c1352 | 2011-04-28 04:39:50 +0000 | [diff] [blame] | 106 | typedef COM_CLASS_TEMPLATE<struct_with_uuid> COM_TYPE_2; |
| 107 | |
Francois Pichet | c867975 | 2011-04-29 09:08:14 +0000 | [diff] [blame] | 108 | template <class T, const GUID& g> |
| 109 | class COM_CLASS_TEMPLATE_REF { }; |
Francois Pichet | 0066db9 | 2012-04-16 04:08:35 +0000 | [diff] [blame] | 110 | typedef COM_CLASS_TEMPLATE_REF<struct_with_uuid, __uuidof(struct_with_uuid)> COM_TYPE_REF; |
Francois Pichet | a1c1352 | 2011-04-28 04:39:50 +0000 | [diff] [blame] | 111 | |
Francois Pichet | 2f019ed | 2011-05-10 00:08:32 +0000 | [diff] [blame] | 112 | struct late_defined_uuid; |
| 113 | template<typename T> |
| 114 | void test_late_defined_uuid() { |
| 115 | __uuidof(late_defined_uuid); |
| 116 | } |
| 117 | struct __declspec(uuid("000000A0-0000-0000-C000-000000000049")) late_defined_uuid; |
| 118 | |
David Majnemer | 61c39a1 | 2013-08-23 05:39:39 +0000 | [diff] [blame] | 119 | COM_CLASS_TEMPLATE_REF<int, __uuidof(struct_with_uuid)> good_template_arg; |
| 120 | |
| 121 | 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}} |
Francois Pichet | 6422579 | 2011-01-18 05:04:39 +0000 | [diff] [blame] | 122 | |
David Majnemer | 59c0ec2 | 2013-09-07 06:59:46 +0000 | [diff] [blame] | 123 | namespace PR16911 { |
| 124 | struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid; |
| 125 | struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid2; |
| 126 | |
| 127 | template <typename T, typename T2> |
| 128 | struct thing { |
| 129 | }; |
| 130 | |
| 131 | struct empty {}; |
| 132 | struct inher : public thing<empty, uuid2> {}; |
| 133 | |
| 134 | struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid; |
| 135 | const struct _GUID *w = &__uuidof(inher); // expected-error{{cannot call operator __uuidof on a type with no GUID}} |
| 136 | const struct _GUID *x = &__uuidof(thing<uuid, inher>); |
| 137 | const struct _GUID *y = &__uuidof(thing<uuid2, uuid>); // expected-error{{cannot call operator __uuidof on a type with multiple GUIDs}} |
| 138 | thing<uuid2, uuid> thing_obj = thing<uuid2, uuid>(); |
| 139 | const struct _GUID *z = &__uuidof(thing_obj); // expected-error{{cannot call operator __uuidof on a type with multiple GUIDs}} |
| 140 | } |
| 141 | |
Aaron Ballman | 3bf758c | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 142 | class CtorCall { |
Francois Pichet | 6422579 | 2011-01-18 05:04:39 +0000 | [diff] [blame] | 143 | public: |
| 144 | CtorCall& operator=(const CtorCall& that); |
| 145 | |
| 146 | int a; |
| 147 | }; |
| 148 | |
| 149 | CtorCall& CtorCall::operator=(const CtorCall& that) |
| 150 | { |
| 151 | if (this != &that) { |
| 152 | this->CtorCall::~CtorCall(); |
| 153 | this->CtorCall::CtorCall(that); // expected-warning {{explicit constructor calls are a Microsoft extension}} |
| 154 | } |
| 155 | return *this; |
| 156 | } |
Francois Pichet | 4e7a2c0 | 2011-03-27 19:41:34 +0000 | [diff] [blame] | 157 | |
| 158 | template <class A> |
| 159 | class C1 { |
| 160 | public: |
| 161 | template <int B> |
| 162 | class Iterator { |
| 163 | }; |
| 164 | }; |
Aaron Ballman | 3bf758c | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 165 | |
Francois Pichet | 4e7a2c0 | 2011-03-27 19:41:34 +0000 | [diff] [blame] | 166 | template<class T> |
| 167 | class C2 { |
| 168 | typename C1<T>:: /*template*/ Iterator<0> Mypos; // expected-warning {{use 'template' keyword to treat 'Iterator' as a dependent template name}} |
| 169 | }; |
| 170 | |
| 171 | template <class T> |
Francois Pichet | 2f019ed | 2011-05-10 00:08:32 +0000 | [diff] [blame] | 172 | void missing_template_keyword(){ |
Francois Pichet | 4e7a2c0 | 2011-03-27 19:41:34 +0000 | [diff] [blame] | 173 | typename C1<T>:: /*template*/ Iterator<0> Mypos; // expected-warning {{use 'template' keyword to treat 'Iterator' as a dependent template name}} |
| 174 | } |
| 175 | |
Francois Pichet | dd87612 | 2011-04-24 11:24:13 +0000 | [diff] [blame] | 176 | |
| 177 | |
David Majnemer | ad01851 | 2013-09-03 22:36:22 +0000 | [diff] [blame] | 178 | class AAAA { |
| 179 | typedef int D; |
| 180 | }; |
Francois Pichet | dd87612 | 2011-04-24 11:24:13 +0000 | [diff] [blame] | 181 | |
Richard Smith | b71e732 | 2012-05-14 22:43:34 +0000 | [diff] [blame] | 182 | template <typename T> |
| 183 | class SimpleTemplate {}; |
| 184 | |
Francois Pichet | dd87612 | 2011-04-24 11:24:13 +0000 | [diff] [blame] | 185 | template <class T> |
| 186 | void redundant_typename() { |
| 187 | typename T t;// expected-warning {{expected a qualified name after 'typename'}} |
| 188 | typename AAAA a;// expected-warning {{expected a qualified name after 'typename'}} |
Richard Smith | b71e732 | 2012-05-14 22:43:34 +0000 | [diff] [blame] | 189 | |
Francois Pichet | dd87612 | 2011-04-24 11:24:13 +0000 | [diff] [blame] | 190 | t = 3; |
Aaron Ballman | 3bf758c | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 191 | |
Richard Smith | b71e732 | 2012-05-14 22:43:34 +0000 | [diff] [blame] | 192 | typedef typename T* pointerT;// expected-warning {{expected a qualified name after 'typename'}} |
| 193 | typedef typename SimpleTemplate<int> templateT;// expected-warning {{expected a qualified name after 'typename'}} |
| 194 | |
| 195 | pointerT pT = &t; |
| 196 | *pT = 4; |
| 197 | |
| 198 | int var; |
| 199 | int k = typename var;// expected-error {{expected a qualified name after 'typename'}} |
Francois Pichet | dd87612 | 2011-04-24 11:24:13 +0000 | [diff] [blame] | 200 | } |
| 201 | |
David Majnemer | ad01851 | 2013-09-03 22:36:22 +0000 | [diff] [blame] | 202 | template <typename T> |
| 203 | struct TypenameWrongPlace { |
| 204 | typename typedef T::D D;// expected-warning {{expected a qualified name after 'typename'}} |
| 205 | }; |
| 206 | |
| 207 | extern TypenameWrongPlace<AAAA> PR16925; |
Joao Matos | e9a3ed4 | 2012-08-31 22:18:20 +0000 | [diff] [blame] | 208 | |
| 209 | __interface MicrosoftInterface; |
| 210 | __interface MicrosoftInterface { |
| 211 | void foo1() = 0; |
| 212 | virtual void foo2() = 0; |
| 213 | }; |
| 214 | |
| 215 | __interface MicrosoftDerivedInterface : public MicrosoftInterface { |
| 216 | void foo1(); |
| 217 | void foo2() override; |
| 218 | void foo3(); |
| 219 | }; |
| 220 | |
| 221 | void interface_test() { |
| 222 | MicrosoftInterface* a; |
| 223 | a->foo1(); |
| 224 | MicrosoftDerivedInterface* b; |
| 225 | b->foo2(); |
| 226 | } |
| 227 | |
| 228 | __int64 x7 = __int64(0); |
Francois Pichet | 4a7de3e | 2011-05-06 20:48:22 +0000 | [diff] [blame] | 229 | |
| 230 | |
Francois Pichet | 8f981d5 | 2011-05-25 10:19:49 +0000 | [diff] [blame] | 231 | namespace If_exists_test { |
Francois Pichet | 4a7de3e | 2011-05-06 20:48:22 +0000 | [diff] [blame] | 232 | |
| 233 | class IF_EXISTS { |
| 234 | private: |
| 235 | typedef int Type; |
| 236 | }; |
| 237 | |
| 238 | int __if_exists_test() { |
Francois Pichet | 4a7de3e | 2011-05-06 20:48:22 +0000 | [diff] [blame] | 239 | int b=0; |
Francois Pichet | 4a7de3e | 2011-05-06 20:48:22 +0000 | [diff] [blame] | 240 | __if_exists(IF_EXISTS::Type) { |
| 241 | b++; |
| 242 | b++; |
| 243 | } |
Francois Pichet | 4a7de3e | 2011-05-06 20:48:22 +0000 | [diff] [blame] | 244 | __if_exists(IF_EXISTS::Type_not) { |
Alp Toker | d473363 | 2013-12-05 04:47:09 +0000 | [diff] [blame] | 245 | this will not compile. |
Francois Pichet | 4a7de3e | 2011-05-06 20:48:22 +0000 | [diff] [blame] | 246 | } |
Francois Pichet | 4a7de3e | 2011-05-06 20:48:22 +0000 | [diff] [blame] | 247 | __if_not_exists(IF_EXISTS::Type) { |
Alp Toker | d473363 | 2013-12-05 04:47:09 +0000 | [diff] [blame] | 248 | this will not compile. |
Francois Pichet | 4a7de3e | 2011-05-06 20:48:22 +0000 | [diff] [blame] | 249 | } |
Francois Pichet | 4a7de3e | 2011-05-06 20:48:22 +0000 | [diff] [blame] | 250 | __if_not_exists(IF_EXISTS::Type_not) { |
| 251 | b++; |
| 252 | b++; |
| 253 | } |
Francois Pichet | a5b3fcb | 2011-05-07 17:30:27 +0000 | [diff] [blame] | 254 | } |
Francois Pichet | 4a7de3e | 2011-05-06 20:48:22 +0000 | [diff] [blame] | 255 | |
Francois Pichet | a5b3fcb | 2011-05-07 17:30:27 +0000 | [diff] [blame] | 256 | |
| 257 | __if_exists(IF_EXISTS::Type) { |
| 258 | int var23; |
| 259 | } |
| 260 | |
| 261 | __if_exists(IF_EXISTS::Type_not) { |
Alp Toker | d473363 | 2013-12-05 04:47:09 +0000 | [diff] [blame] | 262 | this will not compile. |
Francois Pichet | a5b3fcb | 2011-05-07 17:30:27 +0000 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | __if_not_exists(IF_EXISTS::Type) { |
Alp Toker | d473363 | 2013-12-05 04:47:09 +0000 | [diff] [blame] | 266 | this will not compile. |
Francois Pichet | a5b3fcb | 2011-05-07 17:30:27 +0000 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | __if_not_exists(IF_EXISTS::Type_not) { |
| 270 | int var244; |
Francois Pichet | 4a7de3e | 2011-05-06 20:48:22 +0000 | [diff] [blame] | 271 | } |
Francois Pichet | 61d818c | 2011-05-07 17:47:38 +0000 | [diff] [blame] | 272 | |
Francois Pichet | 0251316 | 2011-12-12 23:24:39 +0000 | [diff] [blame] | 273 | int __if_exists_init_list() { |
| 274 | |
Joao Matos | e9a3ed4 | 2012-08-31 22:18:20 +0000 | [diff] [blame] | 275 | int array1[] = { |
Aaron Ballman | 3bf758c | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 276 | 0, |
Joao Matos | e9a3ed4 | 2012-08-31 22:18:20 +0000 | [diff] [blame] | 277 | __if_exists(IF_EXISTS::Type) {2, } |
| 278 | 3 |
| 279 | }; |
Francois Pichet | 0251316 | 2011-12-12 23:24:39 +0000 | [diff] [blame] | 280 | |
Joao Matos | e9a3ed4 | 2012-08-31 22:18:20 +0000 | [diff] [blame] | 281 | int array2[] = { |
Aaron Ballman | 3bf758c | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 282 | 0, |
Alp Toker | d473363 | 2013-12-05 04:47:09 +0000 | [diff] [blame] | 283 | __if_exists(IF_EXISTS::Type_not) { this will not compile } |
Joao Matos | e9a3ed4 | 2012-08-31 22:18:20 +0000 | [diff] [blame] | 284 | 3 |
| 285 | }; |
Francois Pichet | 0251316 | 2011-12-12 23:24:39 +0000 | [diff] [blame] | 286 | |
Joao Matos | e9a3ed4 | 2012-08-31 22:18:20 +0000 | [diff] [blame] | 287 | int array3[] = { |
Aaron Ballman | 3bf758c | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 288 | 0, |
Joao Matos | e9a3ed4 | 2012-08-31 22:18:20 +0000 | [diff] [blame] | 289 | __if_not_exists(IF_EXISTS::Type_not) {2, } |
| 290 | 3 |
| 291 | }; |
| 292 | |
| 293 | int array4[] = { |
Aaron Ballman | 3bf758c | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 294 | 0, |
Alp Toker | d473363 | 2013-12-05 04:47:09 +0000 | [diff] [blame] | 295 | __if_not_exists(IF_EXISTS::Type) { this will not compile } |
Joao Matos | e9a3ed4 | 2012-08-31 22:18:20 +0000 | [diff] [blame] | 296 | 3 |
| 297 | }; |
Francois Pichet | 0251316 | 2011-12-12 23:24:39 +0000 | [diff] [blame] | 298 | |
| 299 | } |
| 300 | |
| 301 | |
Francois Pichet | 8f981d5 | 2011-05-25 10:19:49 +0000 | [diff] [blame] | 302 | class IF_EXISTS_CLASS_TEST { |
| 303 | __if_exists(IF_EXISTS::Type) { |
| 304 | // __if_exists, __if_not_exists can nest |
| 305 | __if_not_exists(IF_EXISTS::Type_not) { |
| 306 | int var123; |
| 307 | } |
| 308 | int var23; |
| 309 | } |
| 310 | |
| 311 | __if_exists(IF_EXISTS::Type_not) { |
Alp Toker | d473363 | 2013-12-05 04:47:09 +0000 | [diff] [blame] | 312 | this will not compile. |
Francois Pichet | 8f981d5 | 2011-05-25 10:19:49 +0000 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | __if_not_exists(IF_EXISTS::Type) { |
Alp Toker | d473363 | 2013-12-05 04:47:09 +0000 | [diff] [blame] | 316 | this will not compile. |
Francois Pichet | 8f981d5 | 2011-05-25 10:19:49 +0000 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | __if_not_exists(IF_EXISTS::Type_not) { |
| 320 | int var244; |
| 321 | } |
| 322 | }; |
| 323 | |
| 324 | } |
| 325 | |
| 326 | |
Francois Pichet | 61d818c | 2011-05-07 17:47:38 +0000 | [diff] [blame] | 327 | int __identifier(generic) = 3; |
| 328 | |
Francois Pichet | 3abc9b8 | 2011-05-11 02:14:46 +0000 | [diff] [blame] | 329 | class inline_definition_pure_spec { |
| 330 | virtual int f() = 0 { return 0; }// expected-warning {{function definition with pure-specifier is a Microsoft extension}} |
| 331 | virtual int f2() = 0; |
| 332 | }; |
| 333 | |
Reid Kleckner | be7a446 | 2013-10-08 22:45:29 +0000 | [diff] [blame] | 334 | struct pure_virtual_dtor { |
| 335 | virtual ~pure_virtual_dtor() = 0; |
| 336 | }; |
| 337 | pure_virtual_dtor::~pure_virtual_dtor() { } |
| 338 | |
| 339 | struct pure_virtual_dtor_inline { |
| 340 | virtual ~pure_virtual_dtor_inline() = 0 { }// expected-warning {{function definition with pure-specifier is a Microsoft extension}} |
| 341 | }; |
| 342 | |
Francois Pichet | 2f019ed | 2011-05-10 00:08:32 +0000 | [diff] [blame] | 343 | |
| 344 | int main () { |
| 345 | // Necessary to force instantiation in -fdelayed-template-parsing mode. |
Aaron Ballman | 3bf758c | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 346 | test_late_defined_uuid<int>(); |
Francois Pichet | 2f019ed | 2011-05-10 00:08:32 +0000 | [diff] [blame] | 347 | redundant_typename<int>(); |
| 348 | missing_template_keyword<int>(); |
| 349 | } |
| 350 | |
John McCall | fa6cf4c | 2012-05-22 21:28:07 +0000 | [diff] [blame] | 351 | namespace access_protected_PTM { |
| 352 | class A { |
| 353 | protected: |
| 354 | void f(); // expected-note {{must name member using the type of the current context 'access_protected_PTM::B'}} |
| 355 | }; |
Francois Pichet | a39371c | 2012-04-17 12:35:05 +0000 | [diff] [blame] | 356 | |
John McCall | fa6cf4c | 2012-05-22 21:28:07 +0000 | [diff] [blame] | 357 | class B : public A{ |
| 358 | public: |
| 359 | void test_access(); |
| 360 | static void test_access_static(); |
| 361 | }; |
Francois Pichet | a39371c | 2012-04-17 12:35:05 +0000 | [diff] [blame] | 362 | |
John McCall | fa6cf4c | 2012-05-22 21:28:07 +0000 | [diff] [blame] | 363 | void B::test_access() { |
| 364 | &A::f; // expected-error {{'f' is a protected member of 'access_protected_PTM::A'}} |
| 365 | } |
| 366 | |
| 367 | void B::test_access_static() { |
| 368 | &A::f; |
| 369 | } |
| 370 | } |
John McCall | 8d32c05 | 2012-05-22 21:28:12 +0000 | [diff] [blame] | 371 | |
| 372 | namespace Inheritance { |
| 373 | class __single_inheritance A; |
| 374 | class __multiple_inheritance B; |
| 375 | class __virtual_inheritance C; |
| 376 | } |
John McCall | 5e77d76 | 2013-04-16 07:28:30 +0000 | [diff] [blame] | 377 | |
| 378 | struct StructWithProperty { |
| 379 | __declspec(property) int V0; // expected-error {{expected '(' after 'property'}} |
| 380 | __declspec(property()) int V1; // expected-error {{property does not specify a getter or a putter}} |
| 381 | __declspec(property(set)) int V2; // expected-error {{putter for property must be specified as 'put', not 'set'}} expected-error {{expected '=' after 'set'}} |
| 382 | __declspec(property(ptu)) int V3; // expected-error {{missing 'get=' or 'put='}} |
| 383 | __declspec(property(ptu=PutV)) int V4; // expected-error {{expected 'get' or 'put' in property declaration}} |
| 384 | __declspec(property(get)) int V5; // expected-error {{expected '=' after 'get'}} |
| 385 | __declspec(property(get&)) int V6; // expected-error {{expected '=' after 'get'}} |
| 386 | __declspec(property(get=)) int V7; // expected-error {{expected name of accessor method}} |
| 387 | __declspec(property(get=GetV)) int V8; // no-warning |
| 388 | __declspec(property(get=GetV=)) int V9; // expected-error {{expected ',' or ')' at end of property accessor list}} |
| 389 | __declspec(property(get=GetV,)) int V10; // expected-error {{expected 'get' or 'put' in property declaration}} |
| 390 | __declspec(property(get=GetV,put=SetV)) int V11; // no-warning |
| 391 | __declspec(property(get=GetV,put=SetV,get=GetV)) int V12; // expected-error {{property declaration specifies 'get' accessor twice}} |
| 392 | |
| 393 | int GetV() { return 123; } |
| 394 | void SetV(int v) {} |
| 395 | }; |
| 396 | void TestProperty() { |
| 397 | StructWithProperty sp; |
| 398 | sp.V8; |
| 399 | sp.V8 = 0; // expected-error {{no setter defined for property 'V8'}} |
| 400 | int i = sp.V11; |
| 401 | sp.V11 = i++; |
| 402 | sp.V11 += 8; |
| 403 | sp.V11++; |
| 404 | ++sp.V11; |
| 405 | } |