MicrosoftExtensions.c revision a2d7dfab309375fbf016b650fa74f9b5d03a9752
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
24
25
26
27
28typedef struct notnested {
29  long bad1;
30  long bad2;
31} NOTNESTED;
32
33
34typedef struct nested1 {
35  long a;
36  struct notnested var1;
37  NOTNESTED var2;
38} NESTED1;
39
40struct nested2 {
41  long b;
42  NESTED1;  // expected-warning {{anonymous structs are a Microsoft extension}}
43};
44
45struct test {
46  int c;
47  struct nested2;   // expected-warning {{anonymous structs are a Microsoft extension}}
48};
49
50void foo()
51{
52  struct test var;
53  var.a;
54  var.b;
55  var.c;
56  var.bad1;   // expected-error {{no member named 'bad1' in 'struct test'}}
57  var.bad2;   // expected-error {{no member named 'bad2' in 'struct test'}}
58}
59
60// Enumeration types with a fixed underlying type.
61const int seventeen = 17;
62typedef int Int;
63
64struct X0 {
65  enum E1 : Int { SomeOtherValue } field;  // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}}
66  enum E1 : seventeen;
67};
68
69enum : long long {  // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}}
70  SomeValue = 0x100000000
71};
72
73
74void pointer_to_integral_type_conv(char* ptr) {
75   char ch = (char)ptr;
76   short sh = (short)ptr;
77   ch = (char)ptr;
78   sh = (short)ptr;
79}
80
81
82typedef struct {
83  UNKNOWN u; // expected-error {{unknown type name 'UNKNOWN'}}
84} AA;
85
86typedef struct {
87  AA; // expected-warning {{anonymous structs are a Microsoft extension}}
88} BB;
89