John McCall | 018591f | 2011-03-02 02:04:40 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -fsyntax-only -Wmicrosoft -verify -fms-extensions -fexceptions -fcxx-exceptions |
Douglas Gregor | 5c0ca52 | 2010-08-30 14:44:26 +0000 | [diff] [blame] | 2 | |
| 3 | |
| 4 | // ::type_info is predeclared with forward class declartion |
| 5 | void f(const type_info &a); |
| 6 | |
Douglas Gregor | 5b6f769 | 2010-08-30 15:04:51 +0000 | [diff] [blame] | 7 | // The following three are all equivalent when ms-extensions are on |
| 8 | void foo() throw(int); |
| 9 | void foo() throw(int, long); |
| 10 | void foo() throw(...); |
| 11 | void foo(); // expected-note {{previous declaration}} |
Douglas Gregor | 5c0ca52 | 2010-08-30 14:44:26 +0000 | [diff] [blame] | 12 | |
Douglas Gregor | 5b6f769 | 2010-08-30 15:04:51 +0000 | [diff] [blame] | 13 | // Only nothrow specification is treated specially. |
| 14 | void foo() throw(); // expected-error {{exception specification in declaration does not match previous declaration}} |
| 15 | |
| 16 | // throw(...) |
| 17 | void r3(); |
| 18 | void r3() throw(...); |
| 19 | |
| 20 | void r6() throw(...); |
| 21 | void r6() throw(int); // okay |
| 22 | |
| 23 | struct Base { |
| 24 | virtual void f2(); |
| 25 | virtual void f3() throw(...); |
| 26 | }; |
| 27 | |
| 28 | struct Derived : Base { |
| 29 | virtual void f2() throw(...); |
| 30 | virtual void f3(); |
| 31 | }; |
Douglas Gregor | afac01d | 2010-09-01 16:29:03 +0000 | [diff] [blame] | 32 | |
Francois Pichet | 538e0d0 | 2010-09-08 11:32:25 +0000 | [diff] [blame] | 33 | |
| 34 | // MSVC allows type definition in anonymous union and struct |
| 35 | struct A |
| 36 | { |
| 37 | union |
| 38 | { |
| 39 | int a; |
| 40 | struct B // expected-warning {{types declared in an anonymous union are a Microsoft extension}} |
| 41 | { |
| 42 | int c; |
| 43 | } d; |
| 44 | |
| 45 | union C // expected-warning {{types declared in an anonymous union are a Microsoft extension}} |
| 46 | { |
| 47 | int e; |
| 48 | int ee; |
| 49 | } f; |
| 50 | |
| 51 | typedef int D; // expected-warning {{types declared in an anonymous union are a Microsoft extension}} |
| 52 | struct F; // expected-warning {{types declared in an anonymous union are a Microsoft extension}} |
| 53 | }; |
| 54 | |
| 55 | struct |
| 56 | { |
| 57 | int a2; |
| 58 | |
| 59 | struct B2 // expected-warning {{types declared in an anonymous struct are a Microsoft extension}} |
| 60 | { |
| 61 | int c2; |
| 62 | } d2; |
| 63 | |
| 64 | union C2 // expected-warning {{types declared in an anonymous struct are a Microsoft extension}} |
| 65 | { |
| 66 | int e2; |
| 67 | int ee2; |
| 68 | } f2; |
| 69 | |
| 70 | typedef int D2; // expected-warning {{types declared in an anonymous struct are a Microsoft extension}} |
| 71 | struct F2; // expected-warning {{types declared in an anonymous struct are a Microsoft extension}} |
| 72 | }; |
| 73 | }; |
| 74 | |
Douglas Gregor | afac01d | 2010-09-01 16:29:03 +0000 | [diff] [blame] | 75 | // __stdcall handling |
| 76 | struct M { |
| 77 | int __stdcall addP(); |
| 78 | float __stdcall subtractP(); |
| 79 | }; |
| 80 | |
| 81 | template<typename T> void h1(T (__stdcall M::* const )()) { } |
| 82 | |
| 83 | void m1() { |
| 84 | h1<int>(&M::addP); |
| 85 | h1(&M::subtractP); |
| 86 | } |
Francois Pichet | 8dc3abc | 2010-09-12 05:06:55 +0000 | [diff] [blame] | 87 | |
| 88 | //MSVC allows forward enum declaration |
| 89 | enum ENUM; // expected-warning {{forward references to 'enum' types are a Microsoft extension}} |
Francois Pichet | 842e7a2 | 2010-10-18 15:01:13 +0000 | [diff] [blame] | 90 | ENUM *var = 0; |
| 91 | ENUM var2 = (ENUM)3; |
| 92 | enum ENUM1* var3 = 0;// expected-warning {{forward references to 'enum' types are a Microsoft extension}} |
| 93 | |
| 94 | |
| 95 | enum ENUM2 { |
| 96 | ENUM2_a = (enum ENUM2) 4, |
| 97 | ENUM2_b = 0x9FFFFFFF, // expected-warning {{enumerator value is not representable in the underlying type 'int'}} |
| 98 | ENUM2_c = 0x100000000 // expected-warning {{enumerator value is not representable in the underlying type 'int'}} |
| 99 | }; |
Francois Pichet | 5be38be | 2011-01-17 01:08:01 +0000 | [diff] [blame] | 100 | |
| 101 | |
| 102 | void f(long long); |
| 103 | void f(int); |
| 104 | |
| 105 | int main() |
| 106 | { |
| 107 | // This is an ambiguous call in standard C++. |
| 108 | // This calls f(long long) in Microsoft mode because LL is always signed. |
| 109 | f(0xffffffffffffffffLL); |
| 110 | f(0xffffffffffffffffi64); |
| 111 | } |
Douglas Gregor | 86f208c | 2011-02-22 20:32:04 +0000 | [diff] [blame] | 112 | |
| 113 | // Enumeration types with a fixed underlying type. |
| 114 | const int seventeen = 17; |
| 115 | typedef int Int; |
| 116 | |
| 117 | struct X0 { |
| 118 | enum E1 : Int { SomeOtherValue } field; // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}} |
| 119 | enum E1 : seventeen; |
| 120 | }; |
| 121 | |
Douglas Gregor | 1756ce4 | 2011-02-22 21:42:31 +0000 | [diff] [blame] | 122 | 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] | 123 | SomeValue = 0x100000000 |
| 124 | }; |