1// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions
2
3
4typedef unsigned short char16_t;
5typedef unsigned int char32_t;
6
7typename decltype(3) a; // expected-warning {{expected a qualified name after 'typename'}}
8
9namespace ms_conversion_rules {
10
11void f(float a);
12void f(int a);
13
14void test()
15{
16    long a = 0;
17    f((long)0);
18	f(a);
19}
20
21}
22
23
24
25namespace ms_protected_scope {
26  struct C { C(); };
27
28  int jump_over_variable_init(bool b) {
29    if (b)
30      goto foo; // expected-warning {{goto into protected scope}}
31    C c; // expected-note {{jump bypasses variable initialization}}
32  foo:
33    return 1;
34  }
35
36struct Y {
37  ~Y();
38};
39
40void jump_over_var_with_dtor() {
41  goto end; // expected-warning{{goto into protected scope}}
42  Y y; // expected-note {{jump bypasses variable with a non-trivial destructor}}
43 end:
44    ;
45}
46
47  void jump_over_variable_case(int c) {
48    switch (c) {
49    case 0:
50      int x = 56; // expected-note {{jump bypasses variable initialization}}
51    case 1:       // expected-error {{switch case is in protected scope}}
52      x = 10;
53    }
54  }
55
56
57void exception_jump() {
58  goto l2; // expected-error {{goto into protected scope}}
59  try { // expected-note {{jump bypasses initialization of try block}}
60     l2: ;
61  } catch(int) {
62  }
63}
64
65int jump_over_indirect_goto() {
66  static void *ps[] = { &&a0 };
67  goto *&&a0; // expected-warning {{goto into protected scope}}
68  int a = 3; // expected-note {{jump bypasses variable initialization}}
69 a0:
70  return 0;
71}
72
73}
74
75namespace PR11826 {
76  struct pair {
77    pair(int v) { }
78    void operator=(pair&& rhs) { }
79  };
80  void f() {
81    pair p0(3);
82    pair p = p0;
83  }
84}
85
86namespace PR11826_for_symmetry {
87  struct pair {
88    pair(int v) { }
89    pair(pair&& rhs) { }
90  };
91  void f() {
92    pair p0(3);
93    pair p(4);
94    p = p0;
95  }
96}
97
98namespace ms_using_declaration_bug {
99
100class A {
101public:
102  int f();
103};
104
105class B : public A {
106private:
107  using A::f;
108};
109
110class C : public B {
111private:
112  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}}
113};
114
115}
116
117
118namespace MissingTypename {
119
120template<class T> class A {
121public:
122	 typedef int TYPE;
123};
124
125template<class T> class B {
126public:
127	 typedef int TYPE;
128};
129
130
131template<class T, class U>
132class C : private A<T>, public B<U> {
133public:
134   typedef A<T> Base1;
135   typedef B<U> Base2;
136   typedef A<U> Base3;
137
138   A<T>::TYPE a1; // expected-warning {{missing 'typename' prior to dependent type name}}
139   Base1::TYPE a2; // expected-warning {{missing 'typename' prior to dependent type name}}
140
141   B<U>::TYPE a3; // expected-warning {{missing 'typename' prior to dependent type name}}
142   Base2::TYPE a4; // expected-warning {{missing 'typename' prior to dependent type name}}
143
144   A<U>::TYPE a5; // expected-error {{missing 'typename' prior to dependent type name}}
145   Base3::TYPE a6; // expected-error {{missing 'typename' prior to dependent type name}}
146 };
147
148class D {
149public:
150    typedef int Type;
151};
152
153template <class T>
154void function_missing_typename(const T::Type param)// expected-warning {{missing 'typename' prior to dependent type name}}
155{
156    const T::Type var = 2; // expected-warning {{missing 'typename' prior to dependent type name}}
157}
158
159template void function_missing_typename<D>(const D::Type param);
160
161}
162
163enum ENUM2 {
164	ENUM2_a = (enum ENUM2) 4,
165	ENUM2_b = 0x9FFFFFFF, // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
166	ENUM2_c = 0x100000000 // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
167};
168
169
170namespace PR11791 {
171  template<class _Ty>
172  void del(_Ty *_Ptr) {
173    _Ptr->~_Ty();  // expected-warning {{pseudo-destructors on type void are a Microsoft extension}}
174  }
175
176  void f() {
177    int* a = 0;
178    del((void*)a);  // expected-note {{in instantiation of function template specialization}}
179  }
180}
181