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 | |
Francois Pichet | 8e161ed | 2010-11-23 06:07:27 +0000 | [diff] [blame] | 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | typedef struct notnested { |
| 29 | long bad1; |
| 30 | long bad2; |
| 31 | } NOTNESTED; |
| 32 | |
| 33 | |
| 34 | typedef struct nested1 { |
| 35 | long a; |
| 36 | struct notnested var1; |
| 37 | NOTNESTED var2; |
| 38 | } NESTED1; |
| 39 | |
| 40 | struct nested2 { |
| 41 | long b; |
| 42 | NESTED1; // expected-warning {{anonymous structs are a Microsoft extension}} |
| 43 | }; |
| 44 | |
| 45 | struct test { |
| 46 | int c; |
| 47 | struct nested2; // expected-warning {{anonymous structs are a Microsoft extension}} |
| 48 | }; |
| 49 | |
| 50 | void 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 | |
Douglas Gregor | 86f208c | 2011-02-22 20:32:04 +0000 | [diff] [blame] | 60 | // Enumeration types with a fixed underlying type. |
| 61 | const int seventeen = 17; |
| 62 | typedef int Int; |
| 63 | |
| 64 | struct 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 | |
Douglas Gregor | 1756ce4 | 2011-02-22 21:42:31 +0000 | [diff] [blame] | 69 | enum : long long { // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}} |
Douglas Gregor | 86f208c | 2011-02-22 20:32:04 +0000 | [diff] [blame] | 70 | SomeValue = 0x100000000 |
| 71 | }; |
Francois Pichet | 83e0995 | 2011-05-11 22:28:19 +0000 | [diff] [blame] | 72 | |
| 73 | |
| 74 | void 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; |
Nico Weber | ee625af | 2012-02-01 00:41:00 +0000 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | |
| 82 | typedef struct { |
| 83 | UNKNOWN u; // expected-error {{unknown type name 'UNKNOWN'}} |
| 84 | } AA; |
| 85 | |
| 86 | typedef struct { |
| 87 | AA; // expected-warning {{anonymous structs are a Microsoft extension}} |
| 88 | } BB; |
Aaron Ballman | 47611c8 | 2012-02-23 01:19:31 +0000 | [diff] [blame] | 89 | |
Fariborz Jahanian | d672436 | 2012-04-23 20:30:52 +0000 | [diff] [blame] | 90 | __declspec(deprecated("This is deprecated")) enum DE1 { one, two } e1; // expected-note {{'e1' declared here}} |
Eli Friedman | c3b2308 | 2012-08-08 21:52:41 +0000 | [diff] [blame] | 91 | struct __declspec(deprecated) DS1 { int i; float f; }; // expected-note {{declared here}} |
Aaron Ballman | 47611c8 | 2012-02-23 01:19:31 +0000 | [diff] [blame] | 92 | |
| 93 | #define MY_TEXT "This is also deprecated" |
Fariborz Jahanian | d672436 | 2012-04-23 20:30:52 +0000 | [diff] [blame] | 94 | __declspec(deprecated(MY_TEXT)) void Dfunc1( void ) {} // expected-note {{'Dfunc1' declared here}} |
Aaron Ballman | 47611c8 | 2012-02-23 01:19:31 +0000 | [diff] [blame] | 95 | |
Aaron Ballman | fc685ac | 2012-06-19 22:09:27 +0000 | [diff] [blame] | 96 | struct __declspec(deprecated(123)) DS2 {}; // expected-error {{argument to deprecated attribute was not a string literal}} |
| 97 | |
Aaron Ballman | 47611c8 | 2012-02-23 01:19:31 +0000 | [diff] [blame] | 98 | void test( void ) { |
| 99 | e1 = one; // expected-warning {{'e1' is deprecated: This is deprecated}} |
| 100 | struct DS1 s = { 0 }; // expected-warning {{'DS1' is deprecated}} |
| 101 | Dfunc1(); // expected-warning {{'Dfunc1' is deprecated: This is also deprecated}} |
| 102 | |
| 103 | enum DE1 no; // no warning because E1 is not deprecated |
| 104 | } |