Francois Pichet | 913b7bf | 2010-12-20 03:51:03 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions |
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 | |
| 7 | [returnvalue:SA_Post( attr=1)] |
| 8 | int foo1([SA_Post(attr=1)] void *param); |
| 9 | |
| 10 | namespace { |
| 11 | [returnvalue:SA_Post(attr=1)] |
| 12 | int foo2([SA_Post(attr=1)] void *param); |
| 13 | } |
| 14 | |
| 15 | class T { |
| 16 | [returnvalue:SA_Post(attr=1)] |
| 17 | int foo3([SA_Post(attr=1)] void *param); |
| 18 | }; |
| 19 | |
| 20 | extern "C" { |
| 21 | [returnvalue:SA_Post(attr=1)] |
| 22 | int foo5([SA_Post(attr=1)] void *param); |
| 23 | } |
| 24 | |
| 25 | |
Francois Pichet | 913b7bf | 2010-12-20 03:51:03 +0000 | [diff] [blame^] | 26 | void uuidof_test1() |
| 27 | { |
| 28 | __uuidof(0); // expected-error {{you need to include <guiddef.h> before using the '__uuidof' operator}} |
| 29 | } |
| 30 | |
| 31 | typedef struct _GUID |
| 32 | { |
| 33 | unsigned long Data1; |
| 34 | unsigned short Data2; |
| 35 | unsigned short Data3; |
| 36 | unsigned char Data4[8]; |
| 37 | } GUID; |
| 38 | |
| 39 | struct __declspec(uuid(L"00000000-0000-0000-1234-000000000047")) uuid_attr_bad1 { };// expected-error {{'uuid' attribute requires parameter 1 to be a string}} |
| 40 | struct __declspec(uuid(3)) uuid_attr_bad2 { };// expected-error {{'uuid' attribute requires parameter 1 to be a string}} |
| 41 | struct __declspec(uuid("0000000-0000-0000-1234-0000500000047")) uuid_attr_bad3 { };// expected-error {{uuid attribute contains a malformed GUID}} |
| 42 | struct __declspec(uuid("0000000-0000-0000-Z234-000000000047")) uuid_attr_bad4 { };// expected-error {{uuid attribute contains a malformed GUID}} |
| 43 | struct __declspec(uuid("000000000000-0000-1234-000000000047")) uuid_attr_bad5 { };// expected-error {{uuid attribute contains a malformed GUID}} |
| 44 | |
| 45 | |
| 46 | |
| 47 | struct __declspec(uuid("000000A0-0000-0000-C000-000000000046")) |
| 48 | struct_with_uuid { }; |
| 49 | struct struct_without_uuid { }; |
| 50 | |
| 51 | |
| 52 | int uuid_sema_test() |
| 53 | { |
| 54 | struct_with_uuid var_with_uuid[1]; |
| 55 | struct_without_uuid var_without_uuid[1]; |
| 56 | |
| 57 | __uuidof(struct_with_uuid); |
| 58 | __uuidof(struct_without_uuid); // expected-error {{cannot call operator __uuidof on a type with no GUID}} |
| 59 | __uuidof(struct_with_uuid*); |
| 60 | __uuidof(struct_without_uuid*); // expected-error {{cannot call operator __uuidof on a type with no GUID}} |
| 61 | |
| 62 | __uuidof(var_with_uuid); |
| 63 | __uuidof(var_without_uuid);// expected-error {{cannot call operator __uuidof on a type with no GUID}} |
| 64 | __uuidof(var_with_uuid[1]); |
| 65 | __uuidof(var_without_uuid[1]);// expected-error {{cannot call operator __uuidof on a type with no GUID}} |
| 66 | __uuidof(&var_with_uuid[1]); |
| 67 | __uuidof(&var_without_uuid[1]);// expected-error {{cannot call operator __uuidof on a type with no GUID}} |
| 68 | |
| 69 | __uuidof(0); |
| 70 | __uuidof(1);// expected-error {{cannot call operator __uuidof on a type with no GUID}} |
| 71 | } |