MicrosoftExtensions.c revision 83e0995105222b078a57e1e20ef71fbfd0f67d3d
1// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions 2 3 4struct A 5{ 6 int a[]; /* expected-warning {{flexible array member 'a' in otherwise empty struct is a Microsoft extension}} */ 7}; 8 9struct C { 10 int l; 11 union { 12 int c1[]; /* expected-warning {{flexible array member 'c1' in a union is a Microsoft extension}} */ 13 char c2[]; /* expected-warning {{flexible array member 'c2' in a union is a Microsoft extension}} */ 14 }; 15}; 16 17 18struct D { 19 int l; 20 int D[]; 21}; 22 23 24enum ENUM1; // expected-warning {{forward references to 'enum' types are a Microsoft extension}} 25enum ENUM1 var1 = 3; 26enum ENUM1* var2 = 0; 27 28 29enum ENUM2 { 30 ENUM2_a = (enum ENUM2) 4, 31 ENUM2_b = 0x9FFFFFFF, // expected-warning {{enumerator value is not representable in the underlying type 'int'}} 32 ENUM2_c = 0x100000000 // expected-warning {{enumerator value is not representable in the underlying type 'int'}} 33}; 34 35 36 37 38typedef struct notnested { 39 long bad1; 40 long bad2; 41} NOTNESTED; 42 43 44typedef struct nested1 { 45 long a; 46 struct notnested var1; 47 NOTNESTED var2; 48} NESTED1; 49 50struct nested2 { 51 long b; 52 NESTED1; // expected-warning {{anonymous structs are a Microsoft extension}} 53}; 54 55struct test { 56 int c; 57 struct nested2; // expected-warning {{anonymous structs are a Microsoft extension}} 58}; 59 60void foo() 61{ 62 struct test var; 63 var.a; 64 var.b; 65 var.c; 66 var.bad1; // expected-error {{no member named 'bad1' in 'struct test'}} 67 var.bad2; // expected-error {{no member named 'bad2' in 'struct test'}} 68} 69 70// Enumeration types with a fixed underlying type. 71const int seventeen = 17; 72typedef int Int; 73 74struct X0 { 75 enum E1 : Int { SomeOtherValue } field; // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}} 76 enum E1 : seventeen; 77}; 78 79enum : long long { // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}} 80 SomeValue = 0x100000000 81}; 82 83 84void pointer_to_integral_type_conv(char* ptr) { 85 char ch = (char)ptr; 86 short sh = (short)ptr; 87 ch = (char)ptr; 88 sh = (short)ptr; 89} 90