diff options
Diffstat (limited to 'test/Parser/MicrosoftExtensions.cpp')
-rw-r--r-- | test/Parser/MicrosoftExtensions.cpp | 156 |
1 files changed, 57 insertions, 99 deletions
diff --git a/test/Parser/MicrosoftExtensions.cpp b/test/Parser/MicrosoftExtensions.cpp index efb5c3ce1fdc..0174ec2f292d 100644 --- a/test/Parser/MicrosoftExtensions.cpp +++ b/test/Parser/MicrosoftExtensions.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions -fms-compatibility -fdelayed-template-parsing +// RUN: %clang_cc1 %s -triple i386-mingw32 -std=c++11 -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions -fms-compatibility -fdelayed-template-parsing /* Microsoft attribute tests */ [repeatable][source_annotation_attribute( Parameter|ReturnValue )] @@ -50,7 +50,7 @@ struct __declspec(uuid("0000000-0000-0000-1234-0000500000047")) uuid_attr_bad3 { 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}} - +__declspec(uuid("000000A0-0000-0000-C000-000000000046")) int i; // expected-warning {{'uuid' attribute only applies to classes}} struct __declspec(uuid("000000A0-0000-0000-C000-000000000046")) struct_with_uuid { }; @@ -227,104 +227,30 @@ void interface_test() { __int64 x7 = __int64(0); - -namespace If_exists_test { - -class IF_EXISTS { -private: - typedef int Type; -}; - -int __if_exists_test() { - int b=0; - __if_exists(IF_EXISTS::Type) { - b++; - b++; - } - __if_exists(IF_EXISTS::Type_not) { - this wont compile. - } - __if_not_exists(IF_EXISTS::Type) { - this wont compile. - } - __if_not_exists(IF_EXISTS::Type_not) { - b++; - b++; - } -} - - -__if_exists(IF_EXISTS::Type) { - int var23; -} - -__if_exists(IF_EXISTS::Type_not) { - this wont compile. -} - -__if_not_exists(IF_EXISTS::Type) { - this wont compile. -} - -__if_not_exists(IF_EXISTS::Type_not) { - int var244; -} - -int __if_exists_init_list() { - - int array1[] = { - 0, - __if_exists(IF_EXISTS::Type) {2, } - 3 - }; - - int array2[] = { - 0, - __if_exists(IF_EXISTS::Type_not) { this wont compile } - 3 - }; - - int array3[] = { - 0, - __if_not_exists(IF_EXISTS::Type_not) {2, } - 3 - }; - - int array4[] = { - 0, - __if_not_exists(IF_EXISTS::Type) { this wont compile } - 3 - }; - -} - - -class IF_EXISTS_CLASS_TEST { - __if_exists(IF_EXISTS::Type) { - // __if_exists, __if_not_exists can nest - __if_not_exists(IF_EXISTS::Type_not) { - int var123; - } - int var23; - } - - __if_exists(IF_EXISTS::Type_not) { - this wont compile. - } - - __if_not_exists(IF_EXISTS::Type) { - this wont compile. - } - - __if_not_exists(IF_EXISTS::Type_not) { - int var244; - } -}; - -} - - int __identifier(generic) = 3; +int __identifier(int) = 4; +struct __identifier(class) { __identifier(class) *__identifier(for); }; +__identifier(class) __identifier(struct) = { &__identifier(struct) }; + +int __identifier for; // expected-error {{missing '(' after '__identifier'}} +int __identifier(else} = __identifier(for); // expected-error {{missing ')' after identifier}} expected-note {{to match this '('}} +#define identifier_weird(x) __identifier(x +int k = identifier_weird(if)); // expected-error {{use of undeclared identifier 'if'}} + +// This is a bit weird, but the alternative tokens aren't keywords, and this +// behavior matches MSVC. FIXME: Consider supporting this anyway. +extern int __identifier(and) r; // expected-error {{cannot convert '&&' token to an identifier}} + +void f() { + __identifier(() // expected-error {{cannot convert '(' token to an identifier}} + __identifier(void) // expected-error {{use of undeclared identifier 'void'}} + __identifier()) // expected-error {{cannot convert ')' token to an identifier}} + // FIXME: We should pick a friendlier display name for this token kind. + __identifier(1) // expected-error {{cannot convert <numeric_constant> token to an identifier}} + __identifier(+) // expected-error {{cannot convert '+' token to an identifier}} + __identifier("foo") // expected-error {{cannot convert <string_literal> token to an identifier}} + __identifier(;) // expected-error {{cannot convert ';' token to an identifier}} +} class inline_definition_pure_spec { virtual int f() = 0 { return 0; }// expected-warning {{function definition with pure-specifier is a Microsoft extension}} @@ -403,3 +329,35 @@ void TestProperty() { sp.V11++; ++sp.V11; } + +//expected-warning@+1 {{C++ operator 'and' (aka '&&') used as a macro name}} +#define and foo + +struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) __declspec(novtable) IUnknown {}; // expected-warning{{__declspec attribute 'novtable' is not supported}} + +typedef bool (__stdcall __stdcall *blarg)(int); + +void local_callconv() { + bool (__stdcall *p)(int); +} + +struct S7 { + int foo() { return 12; } + __declspec(property(get=foo) deprecated) int t; // expected-note {{'t' has been explicitly marked deprecated here}} +}; + +// Technically, this is legal (though it does nothing) +__declspec() void quux( void ) { + struct S7 s; + int i = s.t; // expected-warning {{'t' is deprecated}} +} + +void *_alloca(int); + +void foo(void) { + __declspec(align(16)) int *buffer = (int *)_alloca(9); +} + +template <int *> +struct NullptrArg {}; +NullptrArg<nullptr> a; |