MicrosoftExtensions.cpp revision 018591f524ca4f3a1e657d0d0a66eadf9dbd55f6
1// RUN: %clang_cc1 %s -fsyntax-only -Wmicrosoft -verify -fms-extensions -fexceptions -fcxx-exceptions 2 3 4// ::type_info is predeclared with forward class declartion 5void f(const type_info &a); 6 7// The following three are all equivalent when ms-extensions are on 8void foo() throw(int); 9void foo() throw(int, long); 10void foo() throw(...); 11void foo(); // expected-note {{previous declaration}} 12 13// Only nothrow specification is treated specially. 14void foo() throw(); // expected-error {{exception specification in declaration does not match previous declaration}} 15 16// throw(...) 17void r3(); 18void r3() throw(...); 19 20void r6() throw(...); 21void r6() throw(int); // okay 22 23struct Base { 24 virtual void f2(); 25 virtual void f3() throw(...); 26}; 27 28struct Derived : Base { 29 virtual void f2() throw(...); 30 virtual void f3(); 31}; 32 33 34// MSVC allows type definition in anonymous union and struct 35struct 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 75// __stdcall handling 76struct M { 77 int __stdcall addP(); 78 float __stdcall subtractP(); 79}; 80 81template<typename T> void h1(T (__stdcall M::* const )()) { } 82 83void m1() { 84 h1<int>(&M::addP); 85 h1(&M::subtractP); 86} 87 88//MSVC allows forward enum declaration 89enum ENUM; // expected-warning {{forward references to 'enum' types are a Microsoft extension}} 90ENUM *var = 0; 91ENUM var2 = (ENUM)3; 92enum ENUM1* var3 = 0;// expected-warning {{forward references to 'enum' types are a Microsoft extension}} 93 94 95enum 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}; 100 101 102void f(long long); 103void f(int); 104 105int 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} 112 113// Enumeration types with a fixed underlying type. 114const int seventeen = 17; 115typedef int Int; 116 117struct 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 122enum : long long { // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}} 123 SomeValue = 0x100000000 124}; 125