diff options
Diffstat (limited to 'test/Parser/MicrosoftExtensions.cpp')
-rw-r--r-- | test/Parser/MicrosoftExtensions.cpp | 83 |
1 files changed, 63 insertions, 20 deletions
diff --git a/test/Parser/MicrosoftExtensions.cpp b/test/Parser/MicrosoftExtensions.cpp index d8a597a..efb5c3c 100644 --- a/test/Parser/MicrosoftExtensions.cpp +++ b/test/Parser/MicrosoftExtensions.cpp @@ -4,21 +4,21 @@ [repeatable][source_annotation_attribute( Parameter|ReturnValue )] struct SA_Post{ SA_Post(); int attr; }; -[returnvalue:SA_Post( attr=1)] +[returnvalue:SA_Post( attr=1)] int foo1([SA_Post(attr=1)] void *param); namespace { - [returnvalue:SA_Post(attr=1)] + [returnvalue:SA_Post(attr=1)] int foo2([SA_Post(attr=1)] void *param); } class T { - [returnvalue:SA_Post(attr=1)] + [returnvalue:SA_Post(attr=1)] int foo3([SA_Post(attr=1)] void *param); }; extern "C" { - [returnvalue:SA_Post(attr=1)] + [returnvalue:SA_Post(attr=1)] int foo5([SA_Post(attr=1)] void *param); } @@ -32,7 +32,7 @@ public: void uuidof_test1() -{ +{ __uuidof(0); // expected-error {{you need to include <guiddef.h> before using the '__uuidof' operator}} } @@ -44,8 +44,8 @@ typedef struct _GUID 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(L"00000000-0000-0000-1234-000000000047")) uuid_attr_bad1 { };// expected-error {{'uuid' attribute requires a string}} +struct __declspec(uuid(3)) uuid_attr_bad2 { };// expected-error {{'uuid' attribute requires 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}} @@ -59,7 +59,7 @@ struct struct_without_uuid { }; struct __declspec(uuid("000000A0-0000-0000-C000-000000000049")) struct_with_uuid2; -struct +struct struct_with_uuid2 {} ; int uuid_sema_test() @@ -72,6 +72,10 @@ int uuid_sema_test() __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(struct_with_uuid[1]); + __uuidof(struct_with_uuid*[1]); // expected-error {{cannot call operator __uuidof on a type with no GUID}} + __uuidof(const struct_with_uuid[1][1]); + __uuidof(const struct_with_uuid*[1][1]); // 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}} @@ -89,16 +93,16 @@ template <class T> void template_uuid() { T expr; - + __uuidof(T); __uuidof(expr); } -template <class T, const GUID* g = &__uuidof(T)> +template <class T, const GUID* g = &__uuidof(T)> // expected-note {{template parameter is declared here}} 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, &*&__uuidof(struct_with_uuid)> COM_TYPE_1; // expected-warning {{non-type template argument containing a dereference operation is a Microsoft extension}} typedef COM_CLASS_TEMPLATE<struct_with_uuid> COM_TYPE_2; template <class T, const GUID& g> @@ -112,8 +116,30 @@ typedef COM_CLASS_TEMPLATE_REF<struct_with_uuid, __uuidof(struct_with_uuid)> COM } struct __declspec(uuid("000000A0-0000-0000-C000-000000000049")) late_defined_uuid; +COM_CLASS_TEMPLATE_REF<int, __uuidof(struct_with_uuid)> good_template_arg; + +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}} + +namespace PR16911 { +struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid; +struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid2; + +template <typename T, typename T2> +struct thing { +}; + +struct empty {}; +struct inher : public thing<empty, uuid2> {}; -class CtorCall { +struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid; +const struct _GUID *w = &__uuidof(inher); // expected-error{{cannot call operator __uuidof on a type with no GUID}} +const struct _GUID *x = &__uuidof(thing<uuid, inher>); +const struct _GUID *y = &__uuidof(thing<uuid2, uuid>); // expected-error{{cannot call operator __uuidof on a type with multiple GUIDs}} +thing<uuid2, uuid> thing_obj = thing<uuid2, uuid>(); +const struct _GUID *z = &__uuidof(thing_obj); // expected-error{{cannot call operator __uuidof on a type with multiple GUIDs}} +} + +class CtorCall { public: CtorCall& operator=(const CtorCall& that); @@ -136,7 +162,7 @@ public: 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}} @@ -149,7 +175,9 @@ void missing_template_keyword(){ -class AAAA { }; +class AAAA { + typedef int D; +}; template <typename T> class SimpleTemplate {}; @@ -160,7 +188,7 @@ void redundant_typename() { typename AAAA a;// expected-warning {{expected a qualified name after 'typename'}} t = 3; - + typedef typename T* pointerT;// expected-warning {{expected a qualified name after 'typename'}} typedef typename SimpleTemplate<int> templateT;// expected-warning {{expected a qualified name after 'typename'}} @@ -171,6 +199,12 @@ void redundant_typename() { int k = typename var;// expected-error {{expected a qualified name after 'typename'}} } +template <typename T> +struct TypenameWrongPlace { + typename typedef T::D D;// expected-warning {{expected a qualified name after 'typename'}} +}; + +extern TypenameWrongPlace<AAAA> PR16925; __interface MicrosoftInterface; __interface MicrosoftInterface { @@ -239,25 +273,25 @@ __if_not_exists(IF_EXISTS::Type_not) { int __if_exists_init_list() { int array1[] = { - 0, + 0, __if_exists(IF_EXISTS::Type) {2, } 3 }; int array2[] = { - 0, + 0, __if_exists(IF_EXISTS::Type_not) { this wont compile } 3 }; int array3[] = { - 0, + 0, __if_not_exists(IF_EXISTS::Type_not) {2, } 3 }; int array4[] = { - 0, + 0, __if_not_exists(IF_EXISTS::Type) { this wont compile } 3 }; @@ -297,10 +331,19 @@ class inline_definition_pure_spec { virtual int f2() = 0; }; +struct pure_virtual_dtor { + virtual ~pure_virtual_dtor() = 0; +}; +pure_virtual_dtor::~pure_virtual_dtor() { } + +struct pure_virtual_dtor_inline { + virtual ~pure_virtual_dtor_inline() = 0 { }// expected-warning {{function definition with pure-specifier is a Microsoft extension}} +}; + int main () { // Necessary to force instantiation in -fdelayed-template-parsing mode. - test_late_defined_uuid<int>(); + test_late_defined_uuid<int>(); redundant_typename<int>(); missing_template_keyword<int>(); } |