1// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions -fms-compatibility-version=19.00 2// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions -fms-compatibility-version=18.00 3 4#if defined(_HAS_CHAR16_T_LANGUAGE_SUPPORT) && _HAS_CHAR16_T_LANGUAGE_SUPPORT 5char16_t x; 6char32_t y; 7#else 8typedef unsigned short char16_t; 9typedef unsigned int char32_t; 10#endif 11 12#if _MSC_VER >= 1900 13_Atomic(int) z; 14#else 15struct _Atomic {}; 16#endif 17 18typename decltype(3) a; // expected-warning {{expected a qualified name after 'typename'}} 19 20namespace ms_conversion_rules { 21 22void f(float a); 23void f(int a); 24 25void test() 26{ 27 long a = 0; 28 f((long)0); 29 f(a); 30} 31 32} 33 34 35namespace ms_predefined_types { 36 // ::type_info is a built-in forward class declaration. 37 void f(const type_info &a); 38 void f(size_t); 39} 40 41 42namespace ms_protected_scope { 43 struct C { C(); }; 44 45 int jump_over_variable_init(bool b) { 46 if (b) 47 goto foo; // expected-warning {{jump from this goto statement to its label is a Microsoft extension}} 48 C c; // expected-note {{jump bypasses variable initialization}} 49 foo: 50 return 1; 51 } 52 53struct Y { 54 ~Y(); 55}; 56 57void jump_over_var_with_dtor() { 58 goto end; // expected-warning{{jump from this goto statement to its label is a Microsoft extension}} 59 Y y; // expected-note {{jump bypasses variable with a non-trivial destructor}} 60 end: 61 ; 62} 63 64 void jump_over_variable_case(int c) { 65 switch (c) { 66 case 0: 67 int x = 56; // expected-note {{jump bypasses variable initialization}} 68 case 1: // expected-error {{cannot jump}} 69 x = 10; 70 } 71 } 72 73 74void exception_jump() { 75 goto l2; // expected-error {{cannot jump}} 76 try { // expected-note {{jump bypasses initialization of try block}} 77 l2: ; 78 } catch(int) { 79 } 80} 81 82int jump_over_indirect_goto() { 83 static void *ps[] = { &&a0 }; 84 goto *&&a0; // expected-warning {{jump from this goto statement to its label is a Microsoft extension}} 85 int a = 3; // expected-note {{jump bypasses variable initialization}} 86 a0: 87 return 0; 88} 89 90} 91 92namespace PR11826 { 93 struct pair { 94 pair(int v) { } 95 void operator=(pair&& rhs) { } 96 }; 97 void f() { 98 pair p0(3); 99 pair p = p0; 100 } 101} 102 103namespace PR11826_for_symmetry { 104 struct pair { 105 pair(int v) { } 106 pair(pair&& rhs) { } 107 }; 108 void f() { 109 pair p0(3); 110 pair p(4); 111 p = p0; 112 } 113} 114 115namespace ms_using_declaration_bug { 116 117class A { 118public: 119 int f(); 120}; 121 122class B : public A { 123private: 124 using A::f; 125 void g() { 126 f(); // no diagnostic 127 } 128}; 129 130class C : public B { 131private: 132 using B::f; // expected-warning {{using declaration referring to inaccessible member 'ms_using_declaration_bug::B::f' (which refers to accessible member 'ms_using_declaration_bug::A::f') is a Microsoft compatibility extension}} 133}; 134 135} 136 137namespace using_tag_redeclaration 138{ 139 struct S; 140 namespace N { 141 using ::using_tag_redeclaration::S; 142 struct S {}; // expected-note {{previous definition is here}} 143 } 144 void f() { 145 N::S s1; 146 S s2; 147 } 148 void g() { 149 struct S; // expected-note {{forward declaration of 'S'}} 150 S s3; // expected-error {{variable has incomplete type 'S'}} 151 } 152 void h() { 153 using ::using_tag_redeclaration::S; 154 struct S {}; // expected-error {{redefinition of 'S'}} 155 } 156} 157 158 159namespace MissingTypename { 160 161template<class T> class A { 162public: 163 typedef int TYPE; 164}; 165 166template<class T> class B { 167public: 168 typedef int TYPE; 169}; 170 171 172template<class T, class U> 173class C : private A<T>, public B<U> { 174public: 175 typedef A<T> Base1; 176 typedef B<U> Base2; 177 typedef A<U> Base3; 178 179 A<T>::TYPE a1; // expected-warning {{missing 'typename' prior to dependent type name}} 180 Base1::TYPE a2; // expected-warning {{missing 'typename' prior to dependent type name}} 181 182 B<U>::TYPE a3; // expected-warning {{missing 'typename' prior to dependent type name}} 183 Base2::TYPE a4; // expected-warning {{missing 'typename' prior to dependent type name}} 184 185 A<U>::TYPE a5; // expected-error {{missing 'typename' prior to dependent type name}} 186 Base3::TYPE a6; // expected-error {{missing 'typename' prior to dependent type name}} 187 }; 188 189class D { 190public: 191 typedef int Type; 192}; 193 194template <class T> 195void function_missing_typename(const T::Type param)// expected-warning {{missing 'typename' prior to dependent type name}} 196{ 197 const T::Type var = 2; // expected-warning {{missing 'typename' prior to dependent type name}} 198} 199 200template void function_missing_typename<D>(const D::Type param); 201 202} 203 204enum ENUM2 { 205 ENUM2_a = (enum ENUM2) 4, 206 ENUM2_b = 0x9FFFFFFF, // expected-warning {{enumerator value is not representable in the underlying type 'int'}} 207 ENUM2_c = 0x100000000 // expected-warning {{enumerator value is not representable in the underlying type 'int'}} 208}; 209 210 211namespace PR11791 { 212 template<class _Ty> 213 void del(_Ty *_Ptr) { 214 _Ptr->~_Ty(); // expected-warning {{pseudo-destructors on type void are a Microsoft extension}} 215 } 216 217 void f() { 218 int* a = 0; 219 del((void*)a); // expected-note {{in instantiation of function template specialization}} 220 } 221} 222 223namespace IntToNullPtrConv { 224 struct Foo { 225 static const int ZERO = 0; 226 typedef void (Foo::*MemberFcnPtr)(); 227 }; 228 229 struct Bar { 230 const Foo::MemberFcnPtr pB; 231 }; 232 233 Bar g_bar = { (Foo::MemberFcnPtr)Foo::ZERO }; 234 235 template<int N> int *get_n() { return N; } // expected-warning {{expression which evaluates to zero treated as a null pointer constant}} 236 int *g_nullptr = get_n<0>(); // expected-note {{in instantiation of function template specialization}} 237} 238