1 // RUN: %clang_cc1 -triple i686-windows %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions
6 int a[]; /* expected-warning {{flexible array member 'a' in otherwise empty struct is a Microsoft extension}} */
12 int a[]; /* expected-warning {{flexible array member 'a' in otherwise empty struct is a Microsoft extension}} */
18 int c1[]; /* expected-warning {{flexible array member 'c1' in a union is a Microsoft extension}} */
19 char c2[]; /* expected-warning {{flexible array member 'c2' in a union is a Microsoft extension}} */
29 struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) IUnknown {}; /* expected-error {{'uuid' attribute is not supported in C}} */
31 [uuid("00000000-0000-0000-C000-000000000046")] struct IUnknown2 {}; /* expected-error {{'uuid' attribute is not supported in C}} */
33 typedef struct notnested {
39 typedef struct nested1 {
41 struct notnested var1;
47 NESTED1; // expected-warning {{anonymous structs are a Microsoft extension}}
50 struct nested2 PR20573 = { .a = 3 };
54 struct nested4 { // expected-warning {{anonymous structs are a Microsoft extension}}
57 union nested5 { // expected-warning {{anonymous unions are a Microsoft extension}}
62 typedef union nested6 {
68 struct nested2; // expected-warning {{anonymous structs are a Microsoft extension}}
69 NESTED6; // expected-warning {{anonymous unions are a Microsoft extension}}
78 var.bad1; // expected-error {{no member named 'bad1' in 'struct test'}}
79 var.bad2; // expected-error {{no member named 'bad2' in 'struct test'}}
82 // Enumeration types with a fixed underlying type.
83 const int seventeen = 17;
87 enum E1 : Int { SomeOtherValue } field; // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}}
91 enum : long long { // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}}
92 SomeValue = 0x100000000
96 void pointer_to_integral_type_conv(char* ptr) {
98 short sh = (short)ptr;
102 // This is valid ISO C.
103 _Bool b = (_Bool)ptr;
108 UNKNOWN u; // expected-error {{unknown type name 'UNKNOWN'}}
112 AA; // expected-warning {{anonymous structs are a Microsoft extension}}
116 struct undefined; // expected-warning {{anonymous structs are a Microsoft extension}}
117 // expected-error@-1 {{field has incomplete type 'struct undefined'}}
118 // expected-note@-2 {{forward declaration of 'struct undefined'}}
121 const int anon_falt_size = sizeof(struct anon_fault);
123 __declspec(deprecated("This is deprecated")) enum DE1 { one, two } e1; // expected-note {{'e1' has been explicitly marked deprecated here}}
124 struct __declspec(deprecated) DS1 { int i; float f; }; // expected-note {{'DS1' has been explicitly marked deprecated here}}
126 #define MY_TEXT "This is also deprecated"
127 __declspec(deprecated(MY_TEXT)) void Dfunc1( void ) {} // expected-note {{'Dfunc1' has been explicitly marked deprecated here}}
129 struct __declspec(deprecated(123)) DS2 {}; // expected-error {{'deprecated' attribute requires a string}}
132 e1 = one; // expected-warning {{'e1' is deprecated: This is deprecated}}
133 struct DS1 s = { 0 }; // expected-warning {{'DS1' is deprecated}}
134 Dfunc1(); // expected-warning {{'Dfunc1' is deprecated: This is also deprecated}}
136 enum DE1 no; // no warning because E1 is not deprecated
139 int __sptr wrong1; // expected-error {{'__sptr' attribute only applies to pointer arguments}}
140 // The modifier must follow the asterisk
141 int __sptr *wrong_psp; // expected-error {{'__sptr' attribute only applies to pointer arguments}}
142 int * __sptr __uptr wrong2; // expected-error {{'__sptr' and '__uptr' attributes are not compatible}}
143 int * __sptr __sptr wrong3; // expected-warning {{attribute '__sptr' is already applied}}
145 // It is illegal to overload based on the type attribute.
146 void ptr_func(int * __ptr32 i) {} // expected-note {{previous definition is here}}
147 void ptr_func(int * __ptr64 i) {} // expected-error {{redefinition of 'ptr_func'}}
149 // It is also illegal to overload based on the pointer type attribute.
150 void ptr_func2(int * __sptr __ptr32 i) {} // expected-note {{previous definition is here}}
151 void ptr_func2(int * __uptr __ptr32 i) {} // expected-error {{redefinition of 'ptr_func2'}}
153 int * __sptr __ptr32 __sptr wrong4; // expected-warning {{attribute '__sptr' is already applied}}
155 __ptr32 int *wrong5; // expected-error {{'__ptr32' attribute only applies to pointer arguments}}
157 int *wrong6 __ptr32; // expected-error {{expected ';' after top level declarator}} expected-warning {{declaration does not declare anything}}
159 int * __ptr32 __ptr64 wrong7; // expected-error {{'__ptr32' and '__ptr64' attributes are not compatible}}
161 int * __ptr32 __ptr32 wrong8; // expected-warning {{attribute '__ptr32' is already applied}}
163 int *(__ptr32 __sptr wrong9); // expected-error {{'__sptr' attribute only applies to pointer arguments}} // expected-error {{'__ptr32' attribute only applies to pointer arguments}}
166 T __ptr32 wrong10; // expected-error {{'__ptr32' attribute only applies to pointer arguments}}
168 typedef char *my_va_list;
169 void __va_start(my_va_list *ap, ...); // expected-note {{passing argument to parameter 'ap' here}}
170 void vmyprintf(const char *f, my_va_list ap);
171 void myprintf(const char *f, ...) {
178 __va_start(ap, f); // expected-warning {{incompatible pointer types passing 'my_va_list'}}
182 // __unaligned handling
183 void test_unaligned() {
184 __unaligned int *p1 = 0;
185 int *p2 = p1; // expected-warning {{initializing 'int *' with an expression of type '__unaligned int *' discards qualifiers}}
186 __unaligned int *p3 = p2;
189 void test_unaligned2(int x[__unaligned 4]) {}