1 // RUN: %clang_cc1 -triple i686-windows %s -fsyntax-only -Wno-unused-value -Wno-pointer-to-int-cast -Wmicrosoft -verify -fms-extensions
5 int a
[]; /* expected-warning {{flexible array member 'a' in otherwise empty struct is a Microsoft extension}} */
11 int a
[]; /* expected-warning {{flexible array member 'a' in otherwise empty struct is a Microsoft extension}} */
17 int c1
[]; /* expected-warning {{flexible array member 'c1' in a union is a Microsoft extension}} */
18 char c2
[]; /* expected-warning {{flexible array member 'c2' in a union is a Microsoft extension}} */
28 struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) IUnknown
{}; /* expected-error {{'uuid' attribute is not supported in C}} */
30 [uuid("00000000-0000-0000-C000-000000000046")] struct IUnknown2
{}; /* expected-error {{'uuid' attribute is not supported in C}} */
32 typedef struct notnested
{
38 typedef struct nested1
{
40 struct notnested var1
;
46 NESTED1
; // expected-warning {{anonymous structs are a Microsoft extension}}
49 struct nested2 PR20573
= { .a
= 3 };
53 struct nested4
{ // expected-warning {{anonymous structs are a Microsoft extension}}
56 union nested5
{ // expected-warning {{anonymous unions are a Microsoft extension}}
61 typedef union nested6
{
67 struct nested2
; // expected-warning {{anonymous structs are a Microsoft extension}}
68 NESTED6
; // expected-warning {{anonymous unions are a Microsoft extension}}
77 var
.bad1
; // expected-error {{no member named 'bad1' in 'struct test'}}
78 var
.bad2
; // expected-error {{no member named 'bad2' in 'struct test'}}
81 // Enumeration types with a fixed underlying type.
82 const int seventeen
= 17;
86 enum E1
: Int
{ SomeOtherValue
} field
; // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}}
90 enum : long long { // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}}
91 SomeValue
= 0x100000000
94 void pointer_to_integral_type_conv(char* ptr
) {
96 short sh
= (short)ptr
;
100 // This is valid ISO C.
101 _Bool b
= (_Bool
)ptr
;
105 UNKNOWN u
; // expected-error {{unknown type name 'UNKNOWN'}}
109 AA
; // expected-warning {{anonymous structs are a Microsoft extension}}
113 struct undefined
; // expected-warning {{anonymous structs are a Microsoft extension}}
114 // expected-error@-1 {{field has incomplete type 'struct undefined'}}
115 // expected-note@-2 {{forward declaration of 'struct undefined'}}
118 const int anon_falt_size
= sizeof(struct anon_fault
);
120 __declspec(deprecated("This is deprecated")) enum DE1
{ one
, two
} e1
; // expected-note {{'e1' has been explicitly marked deprecated here}}
121 struct __declspec(deprecated
) DS1
{ int i
; float f
; }; // expected-note {{'DS1' has been explicitly marked deprecated here}}
123 #define MY_TEXT "This is also deprecated"
124 __declspec(deprecated(MY_TEXT
)) void Dfunc1( void ) {} // expected-note {{'Dfunc1' has been explicitly marked deprecated here}}
126 struct __declspec(deprecated(123)) DS2
{}; // expected-error {{'deprecated' attribute requires a string}}
129 e1
= one
; // expected-warning {{'e1' is deprecated: This is deprecated}}
130 struct DS1 s
= { 0 }; // expected-warning {{'DS1' is deprecated}}
131 Dfunc1(); // expected-warning {{'Dfunc1' is deprecated: This is also deprecated}}
133 enum DE1 no
; // no warning because E1 is not deprecated
136 int __sptr wrong1
; // expected-error {{'__sptr' attribute only applies to pointer arguments}}
137 // The modifier must follow the asterisk
138 int __sptr
*wrong_psp
; // expected-error {{'__sptr' attribute only applies to pointer arguments}}
139 int * __sptr __uptr wrong2
; // expected-error {{'__sptr' and '__uptr' attributes are not compatible}}
140 int * __sptr __sptr wrong3
; // expected-warning {{attribute '__sptr' is already applied}}
142 // It is illegal to overload based on the type attribute.
143 void ptr_func(int * __ptr32 i
) {} // expected-note {{previous definition is here}}
144 void ptr_func(int * __ptr64 i
) {} // expected-error {{redefinition of 'ptr_func'}}
146 // It is also illegal to overload based on the pointer type attribute.
147 void ptr_func2(int * __sptr __ptr32 i
) {} // expected-note {{previous definition is here}}
148 void ptr_func2(int * __uptr __ptr32 i
) {} // expected-error {{redefinition of 'ptr_func2'}}
150 // Check for warning when return types have the type attribute.
151 void *__ptr32
ptr_func3(void) { return 0; } // expected-note {{previous definition is here}}
152 void *__ptr64
ptr_func3(void) { return 0; } // expected-error {{redefinition of 'ptr_func3'}}
154 // Test that __ptr32/__ptr64 can be passed as arguments with other address
156 void ptr_func4(int *i
);
157 void ptr_func5(int *__ptr32 i
);
158 void test_ptr_arguments(void) {
164 int * __sptr __ptr32 __sptr wrong4
; // expected-warning {{attribute '__sptr' is already applied}}
166 __ptr32
int *wrong5
; // expected-error {{'__ptr32' attribute only applies to pointer arguments}}
168 int *wrong6 __ptr32
; // expected-error {{expected ';' after top level declarator}} expected-warning {{declaration does not declare anything}}
170 int * __ptr32 __ptr64 wrong7
; // expected-error {{'__ptr32' and '__ptr64' attributes are not compatible}}
172 int * __ptr32 __ptr32 wrong8
; // expected-warning {{attribute '__ptr32' is already applied}}
174 int *(__ptr32 __sptr wrong9
); // expected-error {{'__sptr' attribute only applies to pointer arguments}} // expected-error {{'__ptr32' attribute only applies to pointer arguments}}
176 int *(__ptr32 wrong10
); // expected-error {{'__ptr32' attribute only applies to pointer arguments}}
178 int *(__ptr64 wrong11
); // expected-error {{'__ptr64' attribute only applies to pointer arguments}}
180 int *(__ptr32 __ptr64 wrong12
); // expected-error {{'__ptr32' attribute only applies to pointer arguments}} // expected-error {{'__ptr64' attribute only applies to pointer arguments}}
185 T __ptr32 __ptr64 wrong13
; // expected-error {{'__ptr32' and '__ptr64' attributes are not compatible}}
187 typedef int *__ptr32 T1
;
189 T1 __ptr32 wrong14
; // expected-warning {{attribute '__ptr32' is already applied}}
190 T1 __ptr64 wrong15
; // expected-error {{'__ptr32' and '__ptr64' attributes are not compatible}}
192 typedef int *__ptr64 T2
;
194 T2 __ptr64 wrong16
; // expected-warning {{attribute '__ptr64' is already applied}}
195 T2 __ptr32 wrong17
; // expected-error {{'__ptr32' and '__ptr64' attributes are not compatible}}
197 typedef int *__ptr32 __ptr64 wrong18
; // expected-error {{'__ptr32' and '__ptr64' attributes are not compatible}}
199 typedef char *my_va_list
;
200 void __va_start(my_va_list
*ap
, ...); // expected-note {{passing argument to parameter 'ap' here}}
201 void vmyprintf(const char *f
, my_va_list ap
);
202 void myprintf(const char *f
, ...) {
209 __va_start(ap
, f
); // expected-warning {{incompatible pointer types passing 'my_va_list'}}
213 // __unaligned handling
214 void test_unaligned(void) {
215 __unaligned
int *p1
= 0;
216 int *p2
= p1
; // expected-warning {{initializing 'int *' with an expression of type '__unaligned int *' discards qualifiers}}
217 __unaligned
int *p3
= p2
;
220 void test_unaligned2(int x
[__unaligned
4]) {}