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 5 void f(const type_info &a); 6 7 8 // Microsoft doesn't validate exception specification. 9 namespace microsoft_exception_spec { 10 11 void foo(); // expected-note {{previous declaration}} 12 void foo() throw(); // expected-warning {{exception specification in declaration does not match previous declaration}} 13 14 void r6() throw(...); // expected-note {{previous declaration}} 15 void r6() throw(int); // expected-warning {{exception specification in declaration does not match previous declaration}} 16 17 struct Base { 18 virtual void f2(); 19 virtual void f3() throw(...); 20 }; 21 22 struct Derived : Base { 23 virtual void f2() throw(...); 24 virtual void f3(); 25 }; 26 27 class A { 28 virtual ~A() throw(); // expected-note {{overridden virtual function is here}} 29 }; 30 31 class 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 38 struct 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 79 struct M { 80 int __stdcall addP(); 81 float __stdcall subtractP(); 82 }; 83 84 // __unaligned handling 85 typedef char __unaligned *aligned_type; 86 87 88 template<typename T> void h1(T (__stdcall M::* const )()) { } 89 90 void m1() { 91 h1<int>(&M::addP); 92 h1(&M::subtractP); 93 } 94 95 //MSVC allows forward enum declaration 96 enum ENUM; // expected-warning {{forward references to 'enum' types are a Microsoft extension}} 97 ENUM *var = 0; 98 ENUM var2 = (ENUM)3; 99 enum ENUM1* var3 = 0;// expected-warning {{forward references to 'enum' types are a Microsoft extension}} 100 101 102 103 104 void f(long long); 105 void f(int); 106 107 int main() 108 { 109 // This is an ambiguous call in standard C++. 110 // This calls f(long long) in Microsoft mode because LL is always signed. 111 f(0xffffffffffffffffLL); 112 f(0xffffffffffffffffi64); 113 } 114 115 // Enumeration types with a fixed underlying type. 116 const int seventeen = 17; 117 typedef int Int; 118 119 struct X0 { 120 enum E1 : Int { SomeOtherValue } field; // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}} 121 enum E1 : seventeen; 122 }; 123 124 enum : long long { // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}} 125 SomeValue = 0x100000000 126 }; 127 128 129 class AAA { 130 __declspec(dllimport) void f(void) { } 131 void f2(void); 132 }; 133 134 __declspec(dllimport) void AAA::f2(void) { // expected-error {{dllimport attribute can be applied only to symbol}} 135 136 } 137 138 139 140 template <class T> 141 class BB { 142 public: 143 void f(int g = 10 ); // expected-note {{previous definition is here}} 144 }; 145 146 template <class T> 147 void BB<T>::f(int g = 0) { } // expected-warning {{redefinition of default argument}} 148 149 150 151 extern void static_func(); 152 void static_func(); // expected-note {{previous declaration is here}} 153 154 155 static void static_func() // expected-warning {{static declaration of 'static_func' follows non-static declaration}} 156 { 157 158 } 159 160 long function_prototype(int a); 161 long (*function_ptr)(int a); 162 163 void function_to_voidptr_conv() { 164 void *a1 = function_prototype; 165 void *a2 = &function_prototype; 166 void *a3 = function_ptr; 167 } 168 169 170 void pointer_to_integral_type_conv(char* ptr) { 171 char ch = (char)ptr; 172 short sh = (short)ptr; 173 ch = (char)ptr; 174 sh = (short)ptr; 175 } 176 177 178 namespace friend_as_a_forward_decl { 179 180 class A { 181 class Nested { 182 friend class B; 183 B* b; 184 }; 185 B* b; 186 }; 187 B* global_b; 188 189 190 void f() 191 { 192 class Local { 193 friend class Z; 194 Z* b; 195 }; 196 Z* b; 197 } 198 199 } 200 201 struct PR11150 { 202 class X { 203 virtual void f() = 0; 204 }; 205 206 int array[__is_abstract(X)? 1 : -1]; 207 }; 208 209 void f() { int __except = 0; } 210 211