blob: 1370b7dbf4f178cbf38d6b2c67a7c9c04708f620 [file] [log] [blame]
Francois Pichet8b3c99e2011-09-18 21:48:27 +00001// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -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)
26 goto foo; // expected-warning {{illegal goto into protected scope}}
27 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}}
38 Y y; // expected-note {{jump bypasses variable initialization}}
39 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() {
54 goto l2; // expected-error {{illegal goto into protected scope}}
55 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
71
72
Francois Pichetcc6306e2011-09-20 22:08:26 +000073namespace ms_using_declaration_bug {
74
75class A {
76public:
77 int f();
78};
79
80class B : public A {
81private:
82 using A::f;
83};
84
85class C : public B {
86private:
87 using B::f; // expected-warning {{using declaration refers to inaccessible member 'ms_using_declaration_bug::B::f', which refers to accessible member 'ms_using_declaration_bug::A::f', accepted for Microsoft compatibility}}
88};
89
90}
91
92
Francois Pichet036277e2011-09-21 07:59:49 +000093namespace MissingTypename {
94
95template<class T> class A {
96public:
97 typedef int TYPE;
98};
99
100template<class T> class B {
101public:
102 typedef int TYPE;
103};
104
105
106template<class T, class U>
107class C : private A<T>, public B<U> {
108public:
109 typedef A<T> Base1;
110 typedef B<U> Base2;
111 typedef A<U> Base3;
112
113 A<T>::TYPE a1; // expected-warning {{missing 'typename' prior to dependent type name}}
114 Base1::TYPE a2; // expected-warning {{missing 'typename' prior to dependent type name}}
115
116 B<U>::TYPE a3; // expected-warning {{missing 'typename' prior to dependent type name}}
117 Base2::TYPE a4; // expected-warning {{missing 'typename' prior to dependent type name}}
118
119 A<U>::TYPE a5; // expected-error {{missing 'typename' prior to dependent type name}}
120 Base3::TYPE a6; // expected-error {{missing 'typename' prior to dependent type name}}
121 };
122
123class D {
124public:
125 typedef int Type;
126};
127
128template <class T>
129void function_missing_typename()
130{
131 const T::Type var = 2; // expected-warning {{missing 'typename' prior to dependent type name}}
132}
133
134template void function_missing_typename<D>();
135
136}
Francois Pichetfce1a3a2011-09-24 10:38:05 +0000137
138
139
140namespace lookup_dependent_bases_id_expr {
141
142template<class T> class A {
143public:
144 int var;
145};
146
147
148template<class T>
149class B : public A<T> {
150public:
151 void f() {
152 var = 3;
153 }
154};
155
156template class B<int>;
157
158}