| Francois Pichet | b2d899e | 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 | 141ecfe | 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 | 3cd6feb | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 7 | [returnvalue:SA_Post( attr=1)] |
| Nick Lewycky | 141ecfe | 2010-10-12 16:46:35 +0000 | [diff] [blame] | 8 | int foo1([SA_Post(attr=1)] void *param); |
| 9 | |
| 10 | namespace { |
| Aaron Ballman | 3cd6feb | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 11 | [returnvalue:SA_Post(attr=1)] |
| Nick Lewycky | 141ecfe | 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 | 3cd6feb | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 16 | [returnvalue:SA_Post(attr=1)] |
| Nick Lewycky | 141ecfe | 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 | 3cd6feb | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 21 | [returnvalue:SA_Post(attr=1)] |
| Nick Lewycky | 141ecfe | 2010-10-12 16:46:35 +0000 | [diff] [blame] | 22 | int foo5([SA_Post(attr=1)] void *param); |
| 23 | } |
| 24 | |
| Francois Pichet | dfaa5fb | 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 | 141ecfe | 2010-10-12 16:46:35 +0000 | [diff] [blame] | 33 | |
| Francois Pichet | 913b7bf | 2010-12-20 03:51:03 +0000 | [diff] [blame] | 34 | void uuidof_test1() |
| Aaron Ballman | 3cd6feb | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 35 | { |
| Francois Pichet | 913b7bf | 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 | 3cd6feb | 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 | 913b7bf | 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 | |
| 53 | |
| 54 | |
| 55 | struct __declspec(uuid("000000A0-0000-0000-C000-000000000046")) |
| 56 | struct_with_uuid { }; |
| 57 | struct struct_without_uuid { }; |
| 58 | |
| Francois Pichet | 6915c52 | 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 | 3cd6feb | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 62 | struct |
| Francois Pichet | 6915c52 | 2010-12-27 01:32:00 +0000 | [diff] [blame] | 63 | struct_with_uuid2 {} ; |
| Francois Pichet | 913b7bf | 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 | 6915c52 | 2010-12-27 01:32:00 +0000 | [diff] [blame] | 71 | __uuidof(struct_with_uuid2); |
| Francois Pichet | 913b7bf | 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}} |
| 75 | |
| 76 | __uuidof(var_with_uuid); |
| 77 | __uuidof(var_without_uuid);// expected-error {{cannot call operator __uuidof on a type with no GUID}} |
| 78 | __uuidof(var_with_uuid[1]); |
| 79 | __uuidof(var_without_uuid[1]);// expected-error {{cannot call operator __uuidof on a type with no GUID}} |
| 80 | __uuidof(&var_with_uuid[1]); |
| 81 | __uuidof(&var_without_uuid[1]);// expected-error {{cannot call operator __uuidof on a type with no GUID}} |
| 82 | |
| 83 | __uuidof(0); |
| 84 | __uuidof(1);// expected-error {{cannot call operator __uuidof on a type with no GUID}} |
| 85 | } |
| Francois Pichet | 6915c52 | 2010-12-27 01:32:00 +0000 | [diff] [blame] | 86 | |
| 87 | |
| 88 | template <class T> |
| 89 | void template_uuid() |
| 90 | { |
| 91 | T expr; |
| Aaron Ballman | 3cd6feb | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 92 | |
| Francois Pichet | 6915c52 | 2010-12-27 01:32:00 +0000 | [diff] [blame] | 93 | __uuidof(T); |
| 94 | __uuidof(expr); |
| 95 | } |
| Francois Pichet | dbee341 | 2011-01-18 05:04:39 +0000 | [diff] [blame] | 96 | |
| 97 | |
| David Majnemer | d1282ec | 2013-08-23 05:39:39 +0000 | [diff] [blame] | 98 | template <class T, const GUID* g = &__uuidof(T)> // expected-note {{template parameter is declared here}} |
| Francois Pichet | a97d24f | 2011-04-28 04:39:50 +0000 | [diff] [blame] | 99 | class COM_CLASS_TEMPLATE { }; |
| 100 | |
| David Majnemer | d1282ec | 2013-08-23 05:39:39 +0000 | [diff] [blame] | 101 | 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 | a97d24f | 2011-04-28 04:39:50 +0000 | [diff] [blame] | 102 | typedef COM_CLASS_TEMPLATE<struct_with_uuid> COM_TYPE_2; |
| 103 | |
| Francois Pichet | a343a41 | 2011-04-29 09:08:14 +0000 | [diff] [blame] | 104 | template <class T, const GUID& g> |
| 105 | class COM_CLASS_TEMPLATE_REF { }; |
| Francois Pichet | e275a18 | 2012-04-16 04:08:35 +0000 | [diff] [blame] | 106 | typedef COM_CLASS_TEMPLATE_REF<struct_with_uuid, __uuidof(struct_with_uuid)> COM_TYPE_REF; |
| Francois Pichet | a97d24f | 2011-04-28 04:39:50 +0000 | [diff] [blame] | 107 | |
| Francois Pichet | 20e3c9e | 2011-05-10 00:08:32 +0000 | [diff] [blame] | 108 | struct late_defined_uuid; |
| 109 | template<typename T> |
| 110 | void test_late_defined_uuid() { |
| 111 | __uuidof(late_defined_uuid); |
| 112 | } |
| 113 | struct __declspec(uuid("000000A0-0000-0000-C000-000000000049")) late_defined_uuid; |
| 114 | |
| David Majnemer | d1282ec | 2013-08-23 05:39:39 +0000 | [diff] [blame] | 115 | COM_CLASS_TEMPLATE_REF<int, __uuidof(struct_with_uuid)> good_template_arg; |
| 116 | |
| 117 | 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 | dbee341 | 2011-01-18 05:04:39 +0000 | [diff] [blame] | 118 | |
| Aaron Ballman | 3cd6feb | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 119 | class CtorCall { |
| Francois Pichet | dbee341 | 2011-01-18 05:04:39 +0000 | [diff] [blame] | 120 | public: |
| 121 | CtorCall& operator=(const CtorCall& that); |
| 122 | |
| 123 | int a; |
| 124 | }; |
| 125 | |
| 126 | CtorCall& CtorCall::operator=(const CtorCall& that) |
| 127 | { |
| 128 | if (this != &that) { |
| 129 | this->CtorCall::~CtorCall(); |
| 130 | this->CtorCall::CtorCall(that); // expected-warning {{explicit constructor calls are a Microsoft extension}} |
| 131 | } |
| 132 | return *this; |
| 133 | } |
| Francois Pichet | 4147d30 | 2011-03-27 19:41:34 +0000 | [diff] [blame] | 134 | |
| 135 | template <class A> |
| 136 | class C1 { |
| 137 | public: |
| 138 | template <int B> |
| 139 | class Iterator { |
| 140 | }; |
| 141 | }; |
| Aaron Ballman | 3cd6feb | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 142 | |
| Francois Pichet | 4147d30 | 2011-03-27 19:41:34 +0000 | [diff] [blame] | 143 | template<class T> |
| 144 | class C2 { |
| 145 | typename C1<T>:: /*template*/ Iterator<0> Mypos; // expected-warning {{use 'template' keyword to treat 'Iterator' as a dependent template name}} |
| 146 | }; |
| 147 | |
| 148 | template <class T> |
| Francois Pichet | 20e3c9e | 2011-05-10 00:08:32 +0000 | [diff] [blame] | 149 | void missing_template_keyword(){ |
| Francois Pichet | 4147d30 | 2011-03-27 19:41:34 +0000 | [diff] [blame] | 150 | typename C1<T>:: /*template*/ Iterator<0> Mypos; // expected-warning {{use 'template' keyword to treat 'Iterator' as a dependent template name}} |
| 151 | } |
| 152 | |
| Francois Pichet | a5d318a | 2011-04-24 11:24:13 +0000 | [diff] [blame] | 153 | |
| 154 | |
| David Majnemer | 67ac998 | 2013-09-03 22:36:22 +0000 | [diff] [blame^] | 155 | class AAAA { |
| 156 | typedef int D; |
| 157 | }; |
| Francois Pichet | a5d318a | 2011-04-24 11:24:13 +0000 | [diff] [blame] | 158 | |
| Richard Smith | 2375677 | 2012-05-14 22:43:34 +0000 | [diff] [blame] | 159 | template <typename T> |
| 160 | class SimpleTemplate {}; |
| 161 | |
| Francois Pichet | a5d318a | 2011-04-24 11:24:13 +0000 | [diff] [blame] | 162 | template <class T> |
| 163 | void redundant_typename() { |
| 164 | typename T t;// expected-warning {{expected a qualified name after 'typename'}} |
| 165 | typename AAAA a;// expected-warning {{expected a qualified name after 'typename'}} |
| Richard Smith | 2375677 | 2012-05-14 22:43:34 +0000 | [diff] [blame] | 166 | |
| Francois Pichet | a5d318a | 2011-04-24 11:24:13 +0000 | [diff] [blame] | 167 | t = 3; |
| Aaron Ballman | 3cd6feb | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 168 | |
| Richard Smith | 2375677 | 2012-05-14 22:43:34 +0000 | [diff] [blame] | 169 | typedef typename T* pointerT;// expected-warning {{expected a qualified name after 'typename'}} |
| 170 | typedef typename SimpleTemplate<int> templateT;// expected-warning {{expected a qualified name after 'typename'}} |
| 171 | |
| 172 | pointerT pT = &t; |
| 173 | *pT = 4; |
| 174 | |
| 175 | int var; |
| 176 | int k = typename var;// expected-error {{expected a qualified name after 'typename'}} |
| Francois Pichet | a5d318a | 2011-04-24 11:24:13 +0000 | [diff] [blame] | 177 | } |
| 178 | |
| David Majnemer | 67ac998 | 2013-09-03 22:36:22 +0000 | [diff] [blame^] | 179 | template <typename T> |
| 180 | struct TypenameWrongPlace { |
| 181 | typename typedef T::D D;// expected-warning {{expected a qualified name after 'typename'}} |
| 182 | }; |
| 183 | |
| 184 | extern TypenameWrongPlace<AAAA> PR16925; |
| Joao Matos | 17d35c3 | 2012-08-31 22:18:20 +0000 | [diff] [blame] | 185 | |
| 186 | __interface MicrosoftInterface; |
| 187 | __interface MicrosoftInterface { |
| 188 | void foo1() = 0; |
| 189 | virtual void foo2() = 0; |
| 190 | }; |
| 191 | |
| 192 | __interface MicrosoftDerivedInterface : public MicrosoftInterface { |
| 193 | void foo1(); |
| 194 | void foo2() override; |
| 195 | void foo3(); |
| 196 | }; |
| 197 | |
| 198 | void interface_test() { |
| 199 | MicrosoftInterface* a; |
| 200 | a->foo1(); |
| 201 | MicrosoftDerivedInterface* b; |
| 202 | b->foo2(); |
| 203 | } |
| 204 | |
| 205 | __int64 x7 = __int64(0); |
| Francois Pichet | 1e86269 | 2011-05-06 20:48:22 +0000 | [diff] [blame] | 206 | |
| 207 | |
| Francois Pichet | 563a645 | 2011-05-25 10:19:49 +0000 | [diff] [blame] | 208 | namespace If_exists_test { |
| Francois Pichet | 1e86269 | 2011-05-06 20:48:22 +0000 | [diff] [blame] | 209 | |
| 210 | class IF_EXISTS { |
| 211 | private: |
| 212 | typedef int Type; |
| 213 | }; |
| 214 | |
| 215 | int __if_exists_test() { |
| Francois Pichet | 1e86269 | 2011-05-06 20:48:22 +0000 | [diff] [blame] | 216 | int b=0; |
| Francois Pichet | 1e86269 | 2011-05-06 20:48:22 +0000 | [diff] [blame] | 217 | __if_exists(IF_EXISTS::Type) { |
| 218 | b++; |
| 219 | b++; |
| 220 | } |
| Francois Pichet | 1e86269 | 2011-05-06 20:48:22 +0000 | [diff] [blame] | 221 | __if_exists(IF_EXISTS::Type_not) { |
| 222 | this wont compile. |
| 223 | } |
| Francois Pichet | 1e86269 | 2011-05-06 20:48:22 +0000 | [diff] [blame] | 224 | __if_not_exists(IF_EXISTS::Type) { |
| 225 | this wont compile. |
| 226 | } |
| Francois Pichet | 1e86269 | 2011-05-06 20:48:22 +0000 | [diff] [blame] | 227 | __if_not_exists(IF_EXISTS::Type_not) { |
| 228 | b++; |
| 229 | b++; |
| 230 | } |
| Francois Pichet | f986038 | 2011-05-07 17:30:27 +0000 | [diff] [blame] | 231 | } |
| Francois Pichet | 1e86269 | 2011-05-06 20:48:22 +0000 | [diff] [blame] | 232 | |
| Francois Pichet | f986038 | 2011-05-07 17:30:27 +0000 | [diff] [blame] | 233 | |
| 234 | __if_exists(IF_EXISTS::Type) { |
| 235 | int var23; |
| 236 | } |
| 237 | |
| 238 | __if_exists(IF_EXISTS::Type_not) { |
| 239 | this wont compile. |
| 240 | } |
| 241 | |
| 242 | __if_not_exists(IF_EXISTS::Type) { |
| 243 | this wont compile. |
| 244 | } |
| 245 | |
| 246 | __if_not_exists(IF_EXISTS::Type_not) { |
| 247 | int var244; |
| Francois Pichet | 1e86269 | 2011-05-06 20:48:22 +0000 | [diff] [blame] | 248 | } |
| Francois Pichet | a23ae3f | 2011-05-07 17:47:38 +0000 | [diff] [blame] | 249 | |
| Francois Pichet | 9d24a8b | 2011-12-12 23:24:39 +0000 | [diff] [blame] | 250 | int __if_exists_init_list() { |
| 251 | |
| Joao Matos | 17d35c3 | 2012-08-31 22:18:20 +0000 | [diff] [blame] | 252 | int array1[] = { |
| Aaron Ballman | 3cd6feb | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 253 | 0, |
| Joao Matos | 17d35c3 | 2012-08-31 22:18:20 +0000 | [diff] [blame] | 254 | __if_exists(IF_EXISTS::Type) {2, } |
| 255 | 3 |
| 256 | }; |
| Francois Pichet | 9d24a8b | 2011-12-12 23:24:39 +0000 | [diff] [blame] | 257 | |
| Joao Matos | 17d35c3 | 2012-08-31 22:18:20 +0000 | [diff] [blame] | 258 | int array2[] = { |
| Aaron Ballman | 3cd6feb | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 259 | 0, |
| Joao Matos | 17d35c3 | 2012-08-31 22:18:20 +0000 | [diff] [blame] | 260 | __if_exists(IF_EXISTS::Type_not) { this wont compile } |
| 261 | 3 |
| 262 | }; |
| Francois Pichet | 9d24a8b | 2011-12-12 23:24:39 +0000 | [diff] [blame] | 263 | |
| Joao Matos | 17d35c3 | 2012-08-31 22:18:20 +0000 | [diff] [blame] | 264 | int array3[] = { |
| Aaron Ballman | 3cd6feb | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 265 | 0, |
| Joao Matos | 17d35c3 | 2012-08-31 22:18:20 +0000 | [diff] [blame] | 266 | __if_not_exists(IF_EXISTS::Type_not) {2, } |
| 267 | 3 |
| 268 | }; |
| 269 | |
| 270 | int array4[] = { |
| Aaron Ballman | 3cd6feb | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 271 | 0, |
| Joao Matos | 17d35c3 | 2012-08-31 22:18:20 +0000 | [diff] [blame] | 272 | __if_not_exists(IF_EXISTS::Type) { this wont compile } |
| 273 | 3 |
| 274 | }; |
| Francois Pichet | 9d24a8b | 2011-12-12 23:24:39 +0000 | [diff] [blame] | 275 | |
| 276 | } |
| 277 | |
| 278 | |
| Francois Pichet | 563a645 | 2011-05-25 10:19:49 +0000 | [diff] [blame] | 279 | class IF_EXISTS_CLASS_TEST { |
| 280 | __if_exists(IF_EXISTS::Type) { |
| 281 | // __if_exists, __if_not_exists can nest |
| 282 | __if_not_exists(IF_EXISTS::Type_not) { |
| 283 | int var123; |
| 284 | } |
| 285 | int var23; |
| 286 | } |
| 287 | |
| 288 | __if_exists(IF_EXISTS::Type_not) { |
| 289 | this wont compile. |
| 290 | } |
| 291 | |
| 292 | __if_not_exists(IF_EXISTS::Type) { |
| 293 | this wont compile. |
| 294 | } |
| 295 | |
| 296 | __if_not_exists(IF_EXISTS::Type_not) { |
| 297 | int var244; |
| 298 | } |
| 299 | }; |
| 300 | |
| 301 | } |
| 302 | |
| 303 | |
| Francois Pichet | a23ae3f | 2011-05-07 17:47:38 +0000 | [diff] [blame] | 304 | int __identifier(generic) = 3; |
| 305 | |
| Francois Pichet | 6a24747 | 2011-05-11 02:14:46 +0000 | [diff] [blame] | 306 | class inline_definition_pure_spec { |
| 307 | virtual int f() = 0 { return 0; }// expected-warning {{function definition with pure-specifier is a Microsoft extension}} |
| 308 | virtual int f2() = 0; |
| 309 | }; |
| 310 | |
| Francois Pichet | 20e3c9e | 2011-05-10 00:08:32 +0000 | [diff] [blame] | 311 | |
| 312 | int main () { |
| 313 | // Necessary to force instantiation in -fdelayed-template-parsing mode. |
| Aaron Ballman | 3cd6feb | 2013-07-30 01:31:03 +0000 | [diff] [blame] | 314 | test_late_defined_uuid<int>(); |
| Francois Pichet | 20e3c9e | 2011-05-10 00:08:32 +0000 | [diff] [blame] | 315 | redundant_typename<int>(); |
| 316 | missing_template_keyword<int>(); |
| 317 | } |
| 318 | |
| John McCall | 6c20222 | 2012-05-22 21:28:07 +0000 | [diff] [blame] | 319 | namespace access_protected_PTM { |
| 320 | class A { |
| 321 | protected: |
| 322 | void f(); // expected-note {{must name member using the type of the current context 'access_protected_PTM::B'}} |
| 323 | }; |
| Francois Pichet | b2d899e | 2012-04-17 12:35:05 +0000 | [diff] [blame] | 324 | |
| John McCall | 6c20222 | 2012-05-22 21:28:07 +0000 | [diff] [blame] | 325 | class B : public A{ |
| 326 | public: |
| 327 | void test_access(); |
| 328 | static void test_access_static(); |
| 329 | }; |
| Francois Pichet | b2d899e | 2012-04-17 12:35:05 +0000 | [diff] [blame] | 330 | |
| John McCall | 6c20222 | 2012-05-22 21:28:07 +0000 | [diff] [blame] | 331 | void B::test_access() { |
| 332 | &A::f; // expected-error {{'f' is a protected member of 'access_protected_PTM::A'}} |
| 333 | } |
| 334 | |
| 335 | void B::test_access_static() { |
| 336 | &A::f; |
| 337 | } |
| 338 | } |
| John McCall | c052dbb | 2012-05-22 21:28:12 +0000 | [diff] [blame] | 339 | |
| 340 | namespace Inheritance { |
| 341 | class __single_inheritance A; |
| 342 | class __multiple_inheritance B; |
| 343 | class __virtual_inheritance C; |
| 344 | } |
| John McCall | 76da55d | 2013-04-16 07:28:30 +0000 | [diff] [blame] | 345 | |
| 346 | struct StructWithProperty { |
| 347 | __declspec(property) int V0; // expected-error {{expected '(' after 'property'}} |
| 348 | __declspec(property()) int V1; // expected-error {{property does not specify a getter or a putter}} |
| 349 | __declspec(property(set)) int V2; // expected-error {{putter for property must be specified as 'put', not 'set'}} expected-error {{expected '=' after 'set'}} |
| 350 | __declspec(property(ptu)) int V3; // expected-error {{missing 'get=' or 'put='}} |
| 351 | __declspec(property(ptu=PutV)) int V4; // expected-error {{expected 'get' or 'put' in property declaration}} |
| 352 | __declspec(property(get)) int V5; // expected-error {{expected '=' after 'get'}} |
| 353 | __declspec(property(get&)) int V6; // expected-error {{expected '=' after 'get'}} |
| 354 | __declspec(property(get=)) int V7; // expected-error {{expected name of accessor method}} |
| 355 | __declspec(property(get=GetV)) int V8; // no-warning |
| 356 | __declspec(property(get=GetV=)) int V9; // expected-error {{expected ',' or ')' at end of property accessor list}} |
| 357 | __declspec(property(get=GetV,)) int V10; // expected-error {{expected 'get' or 'put' in property declaration}} |
| 358 | __declspec(property(get=GetV,put=SetV)) int V11; // no-warning |
| 359 | __declspec(property(get=GetV,put=SetV,get=GetV)) int V12; // expected-error {{property declaration specifies 'get' accessor twice}} |
| 360 | |
| 361 | int GetV() { return 123; } |
| 362 | void SetV(int v) {} |
| 363 | }; |
| 364 | void TestProperty() { |
| 365 | StructWithProperty sp; |
| 366 | sp.V8; |
| 367 | sp.V8 = 0; // expected-error {{no setter defined for property 'V8'}} |
| 368 | int i = sp.V11; |
| 369 | sp.V11 = i++; |
| 370 | sp.V11 += 8; |
| 371 | sp.V11++; |
| 372 | ++sp.V11; |
| 373 | } |