Francois Pichet | 8e161ed | 2010-11-23 06:07:27 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions |
Chandler Carruth | b644894 | 2010-10-06 06:50:05 +0000 | [diff] [blame] | 2 | |
| 3 | |
| 4 | struct A |
| 5 | { |
| 6 | int a[]; /* expected-warning {{flexible array member 'a' in otherwise empty struct is a Microsoft extension}} */ |
| 7 | }; |
| 8 | |
| 9 | struct 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 | |
| 18 | struct D { |
| 19 | int l; |
| 20 | int D[]; |
| 21 | }; |
Francois Pichet | 842e7a2 | 2010-10-18 15:01:13 +0000 | [diff] [blame] | 22 | |
| 23 | |
| 24 | enum ENUM1; // expected-warning {{forward references to 'enum' types are a Microsoft extension}} |
| 25 | enum ENUM1 var1 = 3; |
| 26 | enum ENUM1* var2 = 0; |
| 27 | |
| 28 | |
| 29 | enum ENUM2 { |
Francois Pichet | 8e161ed | 2010-11-23 06:07:27 +0000 | [diff] [blame] | 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'}} |
Francois Pichet | 842e7a2 | 2010-10-18 15:01:13 +0000 | [diff] [blame] | 33 | }; |
Francois Pichet | 8e161ed | 2010-11-23 06:07:27 +0000 | [diff] [blame] | 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | typedef struct notnested { |
| 39 | long bad1; |
| 40 | long bad2; |
| 41 | } NOTNESTED; |
| 42 | |
| 43 | |
| 44 | typedef struct nested1 { |
| 45 | long a; |
| 46 | struct notnested var1; |
| 47 | NOTNESTED var2; |
| 48 | } NESTED1; |
| 49 | |
| 50 | struct nested2 { |
| 51 | long b; |
| 52 | NESTED1; // expected-warning {{anonymous structs are a Microsoft extension}} |
| 53 | }; |
| 54 | |
| 55 | struct test { |
| 56 | int c; |
| 57 | struct nested2; // expected-warning {{anonymous structs are a Microsoft extension}} |
| 58 | }; |
| 59 | |
| 60 | void 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 | |
Douglas Gregor | 86f208c | 2011-02-22 20:32:04 +0000 | [diff] [blame^] | 70 | // Enumeration types with a fixed underlying type. |
| 71 | const int seventeen = 17; |
| 72 | typedef int Int; |
| 73 | |
| 74 | struct 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 | |
| 79 | enum : long { // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}} |
| 80 | SomeValue = 0x100000000 |
| 81 | }; |