1// RUN: %clang_cc1 %s -triple i686-pc-win32 -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 8// Microsoft doesn't validate exception specification. 9namespace microsoft_exception_spec { 10 11void foo(); // expected-note {{previous declaration}} 12void foo() throw(); // expected-warning {{exception specification in declaration does not match previous declaration}} 13 14void r6() throw(...); // expected-note {{previous declaration}} 15void r6() throw(int); // expected-warning {{exception specification in declaration does not match previous declaration}} 16 17struct Base { 18 virtual void f2(); 19 virtual void f3() throw(...); 20}; 21 22struct Derived : Base { 23 virtual void f2() throw(...); 24 virtual void f3(); 25}; 26 27class A { 28 virtual ~A() throw(); // expected-note {{overridden virtual function is here}} 29}; 30 31class B : public A { 32 virtual ~B(); // expected-warning {{exception specification of overriding function is more lax than base version}} 33}; 34 35} 36 37// MSVC allows type definition in anonymous union and struct 38struct A 39{ 40 union 41 { 42 int a; 43 struct B // expected-warning {{types declared in an anonymous union are a Microsoft extension}} 44 { 45 int c; 46 } d; 47 48 union C // expected-warning {{types declared in an anonymous union are a Microsoft extension}} 49 { 50 int e; 51 int ee; 52 } f; 53 54 typedef int D; // expected-warning {{types declared in an anonymous union are a Microsoft extension}} 55 struct F; // expected-warning {{types declared in an anonymous union are a Microsoft extension}} 56 }; 57 58 struct 59 { 60 int a2; 61 62 struct B2 // expected-warning {{types declared in an anonymous struct are a Microsoft extension}} 63 { 64 int c2; 65 } d2; 66 67 union C2 // expected-warning {{types declared in an anonymous struct are a Microsoft extension}} 68 { 69 int e2; 70 int ee2; 71 } f2; 72 73 typedef int D2; // expected-warning {{types declared in an anonymous struct are a Microsoft extension}} 74 struct F2; // expected-warning {{types declared in an anonymous struct are a Microsoft extension}} 75 }; 76}; 77 78// __stdcall handling 79struct M { 80 int __stdcall addP(); 81 float __stdcall subtractP(); 82}; 83 84// __unaligned handling 85typedef char __unaligned *aligned_type; 86 87 88template<typename T> void h1(T (__stdcall M::* const )()) { } 89 90void m1() { 91 h1<int>(&M::addP); 92 h1(&M::subtractP); 93} 94 95//MSVC allows forward enum declaration 96enum ENUM; // expected-warning {{forward references to 'enum' types are a Microsoft extension}} 97ENUM *var = 0; 98ENUM var2 = (ENUM)3; 99enum ENUM1* var3 = 0;// expected-warning {{forward references to 'enum' types are a Microsoft extension}} 100 101 102enum ENUM2 { 103 ENUM2_a = (enum ENUM2) 4, 104 ENUM2_b = 0x9FFFFFFF, // expected-warning {{enumerator value is not representable in the underlying type 'int'}} 105 ENUM2_c = 0x100000000 // expected-warning {{enumerator value is not representable in the underlying type 'int'}} 106}; 107 108 109void f(long long); 110void f(int); 111 112int main() 113{ 114 // This is an ambiguous call in standard C++. 115 // This calls f(long long) in Microsoft mode because LL is always signed. 116 f(0xffffffffffffffffLL); 117 f(0xffffffffffffffffi64); 118} 119 120// Enumeration types with a fixed underlying type. 121const int seventeen = 17; 122typedef int Int; 123 124struct X0 { 125 enum E1 : Int { SomeOtherValue } field; // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}} 126 enum E1 : seventeen; 127}; 128 129enum : long long { // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}} 130 SomeValue = 0x100000000 131}; 132 133 134class AAA { 135__declspec(dllimport) void f(void) { } 136void f2(void); 137}; 138 139__declspec(dllimport) void AAA::f2(void) { // expected-error {{dllimport attribute can be applied only to symbol}} 140 141} 142 143 144 145template <class T> 146class BB { 147public: 148 void f(int g = 10 ); // expected-note {{previous definition is here}} 149}; 150 151template <class T> 152void BB<T>::f(int g = 0) { } // expected-warning {{redefinition of default argument}} 153 154 155 156extern void static_func(); 157void static_func(); // expected-note {{previous declaration is here}} 158 159 160static void static_func() // expected-warning {{static declaration of 'static_func' follows non-static declaration}} 161{ 162 163} 164 165long function_prototype(int a); 166long (*function_ptr)(int a); 167 168void function_to_voidptr_conv() { 169 void *a1 = function_prototype; 170 void *a2 = &function_prototype; 171 void *a3 = function_ptr; 172} 173 174 175void pointer_to_integral_type_conv(char* ptr) { 176 char ch = (char)ptr; 177 short sh = (short)ptr; 178 ch = (char)ptr; 179 sh = (short)ptr; 180} 181 182 183namespace friend_as_a_forward_decl { 184 185class A { 186 class Nested { 187 friend class B; 188 B* b; 189 }; 190 B* b; 191}; 192B* global_b; 193 194 195void f() 196{ 197 class Local { 198 friend class Z; 199 Z* b; 200 }; 201 Z* b; 202} 203 204} 205 206struct PR11150 { 207 class X { 208 virtual void f() = 0; 209 }; 210 211 int array[__is_abstract(X)? 1 : -1]; 212}; 213