blob: 90a7ff731c0c90156788e297f1a36a40ba5ba194 [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
4
5namespace ms_conversion_rules {
6
7void f(float a);
8void f(int a);
9
10void test()
11{
12 long a = 0;
13 f((long)0);
14 f(a);
15}
16
17}
18
Francois Pichet8b3c99e2011-09-18 21:48:27 +000019
20
21namespace ms_protected_scope {
22 struct C { C(); };
23
24 int jump_over_variable_init(bool b) {
25 if (b)
Richard Trieu2fe9b7f2011-12-15 00:38:15 +000026 goto foo; // expected-warning {{goto into protected scope}}
Francois Pichet8b3c99e2011-09-18 21:48:27 +000027 C c; // expected-note {{jump bypasses variable initialization}}
28 foo:
29 return 1;
30 }
31
32struct Y {
33 ~Y();
34};
35
36void jump_over_var_with_dtor() {
37 goto end; // expected-warning{{goto into protected scope}}
Richard Smith0e9e9812011-10-20 21:42:12 +000038 Y y; // expected-note {{jump bypasses variable with a non-trivial destructor}}
Francois Pichet8b3c99e2011-09-18 21:48:27 +000039 end:
40 ;
41}
42
43 void jump_over_variable_case(int c) {
44 switch (c) {
45 case 0:
46 int x = 56; // expected-note {{jump bypasses variable initialization}}
47 case 1: // expected-error {{switch case is in protected scope}}
48 x = 10;
49 }
50 }
51
52
53void exception_jump() {
Richard Trieu2fe9b7f2011-12-15 00:38:15 +000054 goto l2; // expected-error {{goto into protected scope}}
Francois Pichet8b3c99e2011-09-18 21:48:27 +000055 try { // expected-note {{jump bypasses initialization of try block}}
56 l2: ;
57 } catch(int) {
58 }
59}
60
61int jump_over_indirect_goto() {
62 static void *ps[] = { &&a0 };
63 goto *&&a0; // expected-warning {{goto into protected scope}}
64 int a = 3; // expected-note {{jump bypasses variable initialization}}
65 a0:
66 return 0;
67}
68
69}
70
Nico Weber28976602012-01-23 04:01:33 +000071namespace PR11826 {
72 struct pair {
73 pair(int v) { }
74 void operator=(pair&& rhs) { }
75 };
76 void f() {
77 pair p0(3);
78 pair p = p0;
79 }
80}
Francois Pichet8b3c99e2011-09-18 21:48:27 +000081
Nico Weber28976602012-01-23 04:01:33 +000082namespace PR11826_for_symmetry {
83 struct pair {
84 pair(int v) { }
85 pair(pair&& rhs) { }
86 };
87 void f() {
88 pair p0(3);
89 pair p(4);
90 p = p0;
91 }
92}
Francois Pichet8b3c99e2011-09-18 21:48:27 +000093
Nico Weberc14ec5a2012-01-23 04:08:13 +000094namespace ms_using_declaration_bug {
95
96class A {
97public:
98 int f();
99};
100
101class B : public A {
102private:
103 using A::f;
104};
105
106class C : public B {
107private:
108 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}}
109};
110
111}
112
113
114namespace MissingTypename {
115
116template<class T> class A {
117public:
118 typedef int TYPE;
119};
120
121template<class T> class B {
122public:
123 typedef int TYPE;
124};
125
126
127template<class T, class U>
128class C : private A<T>, public B<U> {
129public:
130 typedef A<T> Base1;
131 typedef B<U> Base2;
132 typedef A<U> Base3;
133
134 A<T>::TYPE a1; // expected-warning {{missing 'typename' prior to dependent type name}}
135 Base1::TYPE a2; // expected-warning {{missing 'typename' prior to dependent type name}}
136
137 B<U>::TYPE a3; // expected-warning {{missing 'typename' prior to dependent type name}}
138 Base2::TYPE a4; // expected-warning {{missing 'typename' prior to dependent type name}}
139
140 A<U>::TYPE a5; // expected-error {{missing 'typename' prior to dependent type name}}
141 Base3::TYPE a6; // expected-error {{missing 'typename' prior to dependent type name}}
142 };
143
144class D {
145public:
146 typedef int Type;
147};
148
149template <class T>
150void function_missing_typename(const T::Type param)// expected-warning {{missing 'typename' prior to dependent type name}}
151{
152 const T::Type var = 2; // expected-warning {{missing 'typename' prior to dependent type name}}
153}
154
155template void function_missing_typename<D>(const D::Type param);
156
157}
158
Francois Pichet6b6fb4f2012-01-21 23:26:50 +0000159enum ENUM2 {
160 ENUM2_a = (enum ENUM2) 4,
161 ENUM2_b = 0x9FFFFFFF, // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
162 ENUM2_c = 0x100000000 // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
163};
Nico Weberc14ec5a2012-01-23 04:08:13 +0000164
165