blob: 6a48f36801bdfe887b86f26002a30010e04bef4d [file] [log] [blame]
Francois Pichet6b6fb4f2012-01-21 23:26:50 +00001// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions
Francois Pichet1c98d622011-09-18 21:37:37 +00002
3
Francois Pichetdfd110c2012-07-22 11:32:41 +00004typedef unsigned short char16_t;
5typedef unsigned int char32_t;
Francois Pichet1c98d622011-09-18 21:37:37 +00006
Francois Pichetb67e7fc2012-07-22 15:10:57 +00007typename decltype(3) a; // expected-warning {{expected a qualified name after 'typename'}}
8
Francois Pichet1c98d622011-09-18 21:37:37 +00009namespace 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
Francois Pichet8b3c99e2011-09-18 21:48:27 +000023
24
25namespace ms_protected_scope {
26 struct C { C(); };
27
28 int jump_over_variable_init(bool b) {
29 if (b)
Richard Trieu2fe9b7f2011-12-15 00:38:15 +000030 goto foo; // expected-warning {{goto into protected scope}}
Francois Pichet8b3c99e2011-09-18 21:48:27 +000031 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}}
Richard Smith0e9e9812011-10-20 21:42:12 +000042 Y y; // expected-note {{jump bypasses variable with a non-trivial destructor}}
Francois Pichet8b3c99e2011-09-18 21:48:27 +000043 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() {
Richard Trieu2fe9b7f2011-12-15 00:38:15 +000058 goto l2; // expected-error {{goto into protected scope}}
Francois Pichet8b3c99e2011-09-18 21:48:27 +000059 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
Nico Weber28976602012-01-23 04:01:33 +000075namespace 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}
Francois Pichet8b3c99e2011-09-18 21:48:27 +000085
Nico Weber28976602012-01-23 04:01:33 +000086namespace 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}
Francois Pichet8b3c99e2011-09-18 21:48:27 +000097
Nico Weberc14ec5a2012-01-23 04:08:13 +000098namespace 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
Francois Pichet6b6fb4f2012-01-21 23:26:50 +0000163enum 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};
Nico Weberc14ec5a2012-01-23 04:08:13 +0000168
169
Nico Weberdf1be862012-01-23 05:50:57 +0000170namespace 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}