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