xref: /minix3/external/bsd/llvm/dist/clang/test/CXX/drs/dr0xx.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -Wno-bind-to-temporary-copy
2f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
3*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
4*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
5f4a2713aSLionel Sambuc 
6f4a2713aSLionel Sambuc namespace dr1 { // dr1: no
7f4a2713aSLionel Sambuc   namespace X { extern "C" void dr1_f(int a = 1); }
8*0a6a1f1dSLionel Sambuc   namespace Y { extern "C" void dr1_f(int a = 1); }
9f4a2713aSLionel Sambuc   using X::dr1_f; using Y::dr1_f;
g()10f4a2713aSLionel Sambuc   void g() {
11f4a2713aSLionel Sambuc     dr1_f(0);
12f4a2713aSLionel Sambuc     // FIXME: This should be rejected, due to the ambiguous default argument.
13f4a2713aSLionel Sambuc     dr1_f();
14f4a2713aSLionel Sambuc   }
15f4a2713aSLionel Sambuc   namespace X {
16f4a2713aSLionel Sambuc     using Y::dr1_f;
h()17f4a2713aSLionel Sambuc     void h() {
18f4a2713aSLionel Sambuc       dr1_f(0);
19f4a2713aSLionel Sambuc       // FIXME: This should be rejected, due to the ambiguous default argument.
20f4a2713aSLionel Sambuc       dr1_f();
21f4a2713aSLionel Sambuc     }
22f4a2713aSLionel Sambuc   }
23f4a2713aSLionel Sambuc 
24f4a2713aSLionel Sambuc   namespace X {
25f4a2713aSLionel Sambuc     void z(int);
26f4a2713aSLionel Sambuc   }
z(int=1)27f4a2713aSLionel Sambuc   void X::z(int = 1) {} // expected-note {{previous}}
28f4a2713aSLionel Sambuc   namespace X {
29*0a6a1f1dSLionel Sambuc     void z(int = 1); // expected-error {{redefinition of default argument}}
30*0a6a1f1dSLionel Sambuc   }
31*0a6a1f1dSLionel Sambuc 
32*0a6a1f1dSLionel Sambuc   void i(int = 1);
j()33*0a6a1f1dSLionel Sambuc   void j() {
34*0a6a1f1dSLionel Sambuc     void i(int = 1);
35*0a6a1f1dSLionel Sambuc     using dr1::i;
36*0a6a1f1dSLionel Sambuc     i(0);
37*0a6a1f1dSLionel Sambuc     // FIXME: This should be rejected, due to the ambiguous default argument.
38*0a6a1f1dSLionel Sambuc     i();
39*0a6a1f1dSLionel Sambuc   }
k()40*0a6a1f1dSLionel Sambuc   void k() {
41*0a6a1f1dSLionel Sambuc     using dr1::i;
42*0a6a1f1dSLionel Sambuc     void i(int = 1);
43*0a6a1f1dSLionel Sambuc     i(0);
44*0a6a1f1dSLionel Sambuc     // FIXME: This should be rejected, due to the ambiguous default argument.
45*0a6a1f1dSLionel Sambuc     i();
46f4a2713aSLionel Sambuc   }
47f4a2713aSLionel Sambuc }
48f4a2713aSLionel Sambuc 
49f4a2713aSLionel Sambuc namespace dr3 { // dr3: yes
50f4a2713aSLionel Sambuc   template<typename T> struct A {};
f(T)51f4a2713aSLionel Sambuc   template<typename T> void f(T) { A<T> a; } // expected-note {{implicit instantiation}}
52f4a2713aSLionel Sambuc   template void f(int);
53f4a2713aSLionel Sambuc   template<> struct A<int> {}; // expected-error {{explicit specialization of 'dr3::A<int>' after instantiation}}
54f4a2713aSLionel Sambuc }
55f4a2713aSLionel Sambuc 
56f4a2713aSLionel Sambuc namespace dr4 { // dr4: yes
57f4a2713aSLionel Sambuc   extern "C" {
dr4_f(int)58f4a2713aSLionel Sambuc     static void dr4_f(int) {}
dr4_f(float)59f4a2713aSLionel Sambuc     static void dr4_f(float) {}
dr4_g(int)60f4a2713aSLionel Sambuc     void dr4_g(int) {} // expected-note {{previous}}
dr4_g(float)61f4a2713aSLionel Sambuc     void dr4_g(float) {} // expected-error {{conflicting types}}
62f4a2713aSLionel Sambuc   }
63f4a2713aSLionel Sambuc }
64f4a2713aSLionel Sambuc 
65f4a2713aSLionel Sambuc namespace dr5 { // dr5: yes
66f4a2713aSLionel Sambuc   struct A {} a;
67f4a2713aSLionel Sambuc   struct B {
68f4a2713aSLionel Sambuc     B(const A&);
69f4a2713aSLionel Sambuc     B(const B&);
70f4a2713aSLionel Sambuc   };
71f4a2713aSLionel Sambuc   const volatile B b = a;
72f4a2713aSLionel Sambuc 
73f4a2713aSLionel Sambuc   struct C { C(C&); };
74f4a2713aSLionel Sambuc   struct D : C {};
75f4a2713aSLionel Sambuc   struct E { operator D&(); } e;
76f4a2713aSLionel Sambuc   const C c = e;
77f4a2713aSLionel Sambuc }
78f4a2713aSLionel Sambuc 
79f4a2713aSLionel Sambuc namespace dr7 { // dr7: yes
80f4a2713aSLionel Sambuc   class A { public: ~A(); };
81f4a2713aSLionel Sambuc   class B : virtual private A {}; // expected-note 2 {{declared private here}}
82f4a2713aSLionel Sambuc   class C : public B {} c; // expected-error 2 {{inherited virtual base class 'dr7::A' has private destructor}} \
83f4a2713aSLionel Sambuc                            // expected-note {{implicit default constructor for 'dr7::C' first required here}} \
84f4a2713aSLionel Sambuc                            // expected-note {{implicit destructor for 'dr7::C' first required here}}
85f4a2713aSLionel Sambuc   class VeryDerivedC : public B, virtual public A {} vdc;
86f4a2713aSLionel Sambuc 
87f4a2713aSLionel Sambuc   class X { ~X(); }; // expected-note {{here}}
~Y()88f4a2713aSLionel Sambuc   class Y : X { ~Y() {} }; // expected-error {{private destructor}}
89f4a2713aSLionel Sambuc 
90f4a2713aSLionel Sambuc   namespace PR16370 { // This regressed the first time DR7 was fixed.
91f4a2713aSLionel Sambuc     struct S1 { virtual ~S1(); };
92f4a2713aSLionel Sambuc     struct S2 : S1 {};
93f4a2713aSLionel Sambuc     struct S3 : S2 {};
94f4a2713aSLionel Sambuc     struct S4 : virtual S2 {};
95f4a2713aSLionel Sambuc     struct S5 : S3, S4 {
96f4a2713aSLionel Sambuc       S5();
97f4a2713aSLionel Sambuc       ~S5();
98f4a2713aSLionel Sambuc     };
S5()99f4a2713aSLionel Sambuc     S5::S5() {}
100f4a2713aSLionel Sambuc   }
101f4a2713aSLionel Sambuc }
102f4a2713aSLionel Sambuc 
103f4a2713aSLionel Sambuc namespace dr8 { // dr8: dup 45
104f4a2713aSLionel Sambuc   class A {
105f4a2713aSLionel Sambuc     struct U;
106f4a2713aSLionel Sambuc     static const int k = 5;
107f4a2713aSLionel Sambuc     void f();
108f4a2713aSLionel Sambuc     template<typename, int, void (A::*)()> struct T;
109f4a2713aSLionel Sambuc 
110f4a2713aSLionel Sambuc     T<U, k, &A::f> *g();
111f4a2713aSLionel Sambuc   };
g()112f4a2713aSLionel Sambuc   A::T<A::U, A::k, &A::f> *A::g() { return 0; }
113f4a2713aSLionel Sambuc }
114f4a2713aSLionel Sambuc 
115f4a2713aSLionel Sambuc namespace dr9 { // dr9: yes
116f4a2713aSLionel Sambuc   struct B {
117f4a2713aSLionel Sambuc   protected:
118f4a2713aSLionel Sambuc     int m; // expected-note {{here}}
119f4a2713aSLionel Sambuc     friend int R1();
120f4a2713aSLionel Sambuc   };
121f4a2713aSLionel Sambuc   struct N : protected B { // expected-note 2{{protected}}
122f4a2713aSLionel Sambuc     friend int R2();
123f4a2713aSLionel Sambuc   } n;
R1()124f4a2713aSLionel Sambuc   int R1() { return n.m; } // expected-error {{protected base class}} expected-error {{protected member}}
R2()125f4a2713aSLionel Sambuc   int R2() { return n.m; }
126f4a2713aSLionel Sambuc }
127f4a2713aSLionel Sambuc 
128f4a2713aSLionel Sambuc namespace dr10 { // dr10: dup 45
129f4a2713aSLionel Sambuc   class A {
130f4a2713aSLionel Sambuc     struct B {
131f4a2713aSLionel Sambuc       A::B *p;
132f4a2713aSLionel Sambuc     };
133f4a2713aSLionel Sambuc   };
134f4a2713aSLionel Sambuc }
135f4a2713aSLionel Sambuc 
136f4a2713aSLionel Sambuc namespace dr11 { // dr11: yes
137f4a2713aSLionel Sambuc   template<typename T> struct A : T {
138f4a2713aSLionel Sambuc     using typename T::U;
139f4a2713aSLionel Sambuc     U u;
140f4a2713aSLionel Sambuc   };
141f4a2713aSLionel Sambuc   template<typename T> struct B : T {
142f4a2713aSLionel Sambuc     using T::V;
143f4a2713aSLionel Sambuc     V v; // expected-error {{unknown type name}}
144f4a2713aSLionel Sambuc   };
145f4a2713aSLionel Sambuc   struct X { typedef int U; };
146f4a2713aSLionel Sambuc   A<X> ax;
147f4a2713aSLionel Sambuc }
148f4a2713aSLionel Sambuc 
149f4a2713aSLionel Sambuc namespace dr12 { // dr12: sup 239
150f4a2713aSLionel Sambuc   enum E { e };
151f4a2713aSLionel Sambuc   E &f(E, E = e);
g()152f4a2713aSLionel Sambuc   void g() {
153f4a2713aSLionel Sambuc     int &f(int, E = e);
154f4a2713aSLionel Sambuc     // Under DR12, these call two different functions.
155f4a2713aSLionel Sambuc     // Under DR239, they call the same function.
156f4a2713aSLionel Sambuc     int &b = f(e);
157f4a2713aSLionel Sambuc     int &c = f(1);
158f4a2713aSLionel Sambuc   }
159f4a2713aSLionel Sambuc }
160f4a2713aSLionel Sambuc 
161*0a6a1f1dSLionel Sambuc namespace dr13 { // dr13: no
162*0a6a1f1dSLionel Sambuc   extern "C" void f(int);
163*0a6a1f1dSLionel Sambuc   void g(char);
164*0a6a1f1dSLionel Sambuc 
165*0a6a1f1dSLionel Sambuc   template<typename T> struct A {
166*0a6a1f1dSLionel Sambuc     A(void (*fp)(T));
167*0a6a1f1dSLionel Sambuc   };
168*0a6a1f1dSLionel Sambuc   template<typename T> int h(void (T));
169*0a6a1f1dSLionel Sambuc 
170*0a6a1f1dSLionel Sambuc   A<int> a1(f); // FIXME: We should reject this.
171*0a6a1f1dSLionel Sambuc   A<char> a2(g);
172*0a6a1f1dSLionel Sambuc   int a3 = h(f); // FIXME: We should reject this.
173*0a6a1f1dSLionel Sambuc   int a4 = h(g);
174*0a6a1f1dSLionel Sambuc }
175*0a6a1f1dSLionel Sambuc 
176f4a2713aSLionel Sambuc namespace dr14 { // dr14: yes
177f4a2713aSLionel Sambuc   namespace X { extern "C" int dr14_f(); }
178f4a2713aSLionel Sambuc   namespace Y { extern "C" int dr14_f(); }
179f4a2713aSLionel Sambuc   using namespace X;
180f4a2713aSLionel Sambuc   using namespace Y;
181f4a2713aSLionel Sambuc   int k = dr14_f();
182f4a2713aSLionel Sambuc 
183f4a2713aSLionel Sambuc   class C {
184f4a2713aSLionel Sambuc     int k;
185f4a2713aSLionel Sambuc     friend int Y::dr14_f();
186f4a2713aSLionel Sambuc   } c;
187f4a2713aSLionel Sambuc   namespace Z {
dr14_f()188f4a2713aSLionel Sambuc     extern "C" int dr14_f() { return c.k; }
189f4a2713aSLionel Sambuc   }
190f4a2713aSLionel Sambuc 
191f4a2713aSLionel Sambuc   namespace X { typedef int T; typedef int U; } // expected-note {{candidate}}
192f4a2713aSLionel Sambuc   namespace Y { typedef int T; typedef long U; } // expected-note {{candidate}}
193f4a2713aSLionel Sambuc   T t; // ok, same type both times
194f4a2713aSLionel Sambuc   U u; // expected-error {{ambiguous}}
195f4a2713aSLionel Sambuc }
196f4a2713aSLionel Sambuc 
197f4a2713aSLionel Sambuc namespace dr15 { // dr15: yes
198f4a2713aSLionel Sambuc   template<typename T> void f(int); // expected-note {{previous}}
199f4a2713aSLionel Sambuc   template<typename T> void f(int = 0); // expected-error {{default arguments cannot be added}}
200f4a2713aSLionel Sambuc }
201f4a2713aSLionel Sambuc 
202f4a2713aSLionel Sambuc namespace dr16 { // dr16: yes
203f4a2713aSLionel Sambuc   class A { // expected-note {{here}}
204f4a2713aSLionel Sambuc     void f(); // expected-note {{here}}
205f4a2713aSLionel Sambuc     friend class C;
206f4a2713aSLionel Sambuc   };
207f4a2713aSLionel Sambuc   class B : A {}; // expected-note 4{{here}}
208f4a2713aSLionel Sambuc   class C : B {
g()209f4a2713aSLionel Sambuc     void g() {
210f4a2713aSLionel Sambuc       f(); // expected-error {{private member}} expected-error {{private base}}
211f4a2713aSLionel Sambuc       A::f(); // expected-error {{private member}} expected-error {{private base}}
212f4a2713aSLionel Sambuc     }
213f4a2713aSLionel Sambuc   };
214f4a2713aSLionel Sambuc }
215f4a2713aSLionel Sambuc 
216f4a2713aSLionel Sambuc namespace dr17 { // dr17: yes
217f4a2713aSLionel Sambuc   class A {
218f4a2713aSLionel Sambuc     int n;
219f4a2713aSLionel Sambuc     int f();
220f4a2713aSLionel Sambuc     struct C;
221f4a2713aSLionel Sambuc   };
222f4a2713aSLionel Sambuc   struct B : A {} b;
f()223f4a2713aSLionel Sambuc   int A::f() { return b.n; }
224f4a2713aSLionel Sambuc   struct A::C : A {
gdr17::A::C225f4a2713aSLionel Sambuc     int g() { return n; }
226f4a2713aSLionel Sambuc   };
227f4a2713aSLionel Sambuc }
228f4a2713aSLionel Sambuc 
229*0a6a1f1dSLionel Sambuc // dr18: sup 577
230f4a2713aSLionel Sambuc 
231f4a2713aSLionel Sambuc namespace dr19 { // dr19: yes
232f4a2713aSLionel Sambuc   struct A {
233f4a2713aSLionel Sambuc     int n; // expected-note {{here}}
234f4a2713aSLionel Sambuc   };
235f4a2713aSLionel Sambuc   struct B : protected A { // expected-note {{here}}
236f4a2713aSLionel Sambuc   };
237f4a2713aSLionel Sambuc   struct C : B {} c;
238f4a2713aSLionel Sambuc   struct D : B {
get1dr19::D239f4a2713aSLionel Sambuc     int get1() { return c.n; } // expected-error {{protected member}}
get2dr19::D240f4a2713aSLionel Sambuc     int get2() { return ((A&)c).n; } // ok, A is an accessible base of B from here
241f4a2713aSLionel Sambuc   };
242f4a2713aSLionel Sambuc }
243f4a2713aSLionel Sambuc 
244f4a2713aSLionel Sambuc namespace dr20 { // dr20: yes
245f4a2713aSLionel Sambuc   class X {
246f4a2713aSLionel Sambuc   public:
247f4a2713aSLionel Sambuc     X();
248f4a2713aSLionel Sambuc   private:
249f4a2713aSLionel Sambuc     X(const X&); // expected-note {{here}}
250f4a2713aSLionel Sambuc   };
251f4a2713aSLionel Sambuc   X f();
252f4a2713aSLionel Sambuc   X x = f(); // expected-error {{private}}
253f4a2713aSLionel Sambuc }
254f4a2713aSLionel Sambuc 
255f4a2713aSLionel Sambuc namespace dr21 { // dr21: yes
256f4a2713aSLionel Sambuc   template<typename T> struct A;
257f4a2713aSLionel Sambuc   struct X {
258f4a2713aSLionel Sambuc     template<typename T = int> friend struct A; // expected-error {{default template argument not permitted on a friend template}}
259f4a2713aSLionel Sambuc     template<typename T = int> friend struct B; // expected-error {{default template argument not permitted on a friend template}}
260f4a2713aSLionel Sambuc   };
261f4a2713aSLionel Sambuc }
262f4a2713aSLionel Sambuc 
263f4a2713aSLionel Sambuc namespace dr22 { // dr22: sup 481
264f4a2713aSLionel Sambuc   template<typename dr22_T = dr22_T> struct X; // expected-error {{unknown type name 'dr22_T'}}
265f4a2713aSLionel Sambuc   typedef int T;
266f4a2713aSLionel Sambuc   template<typename T = T> struct Y;
267f4a2713aSLionel Sambuc }
268f4a2713aSLionel Sambuc 
269f4a2713aSLionel Sambuc namespace dr23 { // dr23: yes
270f4a2713aSLionel Sambuc   template<typename T> void f(T, T); // expected-note {{candidate}}
271f4a2713aSLionel Sambuc   template<typename T> void f(T, int); // expected-note {{candidate}}
g()272f4a2713aSLionel Sambuc   void g() { f(0, 0); } // expected-error {{ambiguous}}
273f4a2713aSLionel Sambuc }
274f4a2713aSLionel Sambuc 
275f4a2713aSLionel Sambuc // dr24: na
276f4a2713aSLionel Sambuc 
277f4a2713aSLionel Sambuc namespace dr25 { // dr25: yes
278f4a2713aSLionel Sambuc   struct A {
279f4a2713aSLionel Sambuc     void f() throw(int);
280f4a2713aSLionel Sambuc   };
281f4a2713aSLionel Sambuc   void (A::*f)() throw (int);
282f4a2713aSLionel Sambuc   void (A::*g)() throw () = f; // expected-error {{is not superset of source}}
283f4a2713aSLionel Sambuc   void (A::*g2)() throw () = 0;
284f4a2713aSLionel Sambuc   void (A::*h)() throw (int, char) = f;
285f4a2713aSLionel Sambuc   void (A::*i)() throw () = &A::f; // expected-error {{is not superset of source}}
286f4a2713aSLionel Sambuc   void (A::*i2)() throw () = 0;
287f4a2713aSLionel Sambuc   void (A::*j)() throw (int, char) = &A::f;
x()288f4a2713aSLionel Sambuc   void x() {
289f4a2713aSLionel Sambuc     // FIXME: Don't produce the second error here.
290f4a2713aSLionel Sambuc     g2 = f; // expected-error {{is not superset}} expected-error {{incompatible}}
291f4a2713aSLionel Sambuc     h = f;
292f4a2713aSLionel Sambuc     i2 = &A::f; // expected-error {{is not superset}} expected-error {{incompatible}}
293f4a2713aSLionel Sambuc     j = &A::f;
294f4a2713aSLionel Sambuc   }
295f4a2713aSLionel Sambuc }
296f4a2713aSLionel Sambuc 
297f4a2713aSLionel Sambuc namespace dr26 { // dr26: yes
298f4a2713aSLionel Sambuc   struct A { A(A, const A & = A()); }; // expected-error {{must pass its first argument by reference}}
299f4a2713aSLionel Sambuc   struct B {
300f4a2713aSLionel Sambuc     B(); // expected-note {{candidate}}
301f4a2713aSLionel Sambuc     B(const B &, B = B()); // expected-error {{no matching constructor}} expected-note {{candidate}} expected-note {{here}}
302f4a2713aSLionel Sambuc   };
303f4a2713aSLionel Sambuc }
304f4a2713aSLionel Sambuc 
305f4a2713aSLionel Sambuc namespace dr27 { // dr27: yes
306f4a2713aSLionel Sambuc   enum E { e } n;
307f4a2713aSLionel Sambuc   E &m = true ? n : n;
308f4a2713aSLionel Sambuc }
309f4a2713aSLionel Sambuc 
310f4a2713aSLionel Sambuc // dr28: na
311f4a2713aSLionel Sambuc 
312f4a2713aSLionel Sambuc namespace dr29 { // dr29: 3.4
313f4a2713aSLionel Sambuc   void dr29_f0(); // expected-note {{here}}
g0()314f4a2713aSLionel Sambuc   void g0() { void dr29_f0(); }
g0_cxx()315f4a2713aSLionel Sambuc   extern "C++" void g0_cxx() { void dr29_f0(); }
g0_c()316f4a2713aSLionel Sambuc   extern "C" void g0_c() { void dr29_f0(); } // expected-error {{different language linkage}}
317f4a2713aSLionel Sambuc 
318f4a2713aSLionel Sambuc   extern "C" void dr29_f1(); // expected-note {{here}}
g1()319f4a2713aSLionel Sambuc   void g1() { void dr29_f1(); }
g1_c()320f4a2713aSLionel Sambuc   extern "C" void g1_c() { void dr29_f1(); }
g1_cxx()321f4a2713aSLionel Sambuc   extern "C++" void g1_cxx() { void dr29_f1(); } // expected-error {{different language linkage}}
322f4a2713aSLionel Sambuc 
g2()323f4a2713aSLionel Sambuc   void g2() { void dr29_f2(); } // expected-note {{here}}
324f4a2713aSLionel Sambuc   extern "C" void dr29_f2(); // expected-error {{different language linkage}}
325f4a2713aSLionel Sambuc 
g3()326f4a2713aSLionel Sambuc   extern "C" void g3() { void dr29_f3(); } // expected-note {{here}}
327f4a2713aSLionel Sambuc   extern "C++" void dr29_f3(); // expected-error {{different language linkage}}
328f4a2713aSLionel Sambuc 
g4()329f4a2713aSLionel Sambuc   extern "C++" void g4() { void dr29_f4(); } // expected-note {{here}}
330f4a2713aSLionel Sambuc   extern "C" void dr29_f4(); // expected-error {{different language linkage}}
331f4a2713aSLionel Sambuc 
332f4a2713aSLionel Sambuc   extern "C" void g5();
333f4a2713aSLionel Sambuc   extern "C++" void dr29_f5();
g5()334f4a2713aSLionel Sambuc   void g5() {
335f4a2713aSLionel Sambuc     void dr29_f5(); // ok, g5 is extern "C" but we're not inside the linkage-specification here.
336f4a2713aSLionel Sambuc   }
337f4a2713aSLionel Sambuc 
338f4a2713aSLionel Sambuc   extern "C++" void g6();
339f4a2713aSLionel Sambuc   extern "C" void dr29_f6();
g6()340f4a2713aSLionel Sambuc   void g6() {
341f4a2713aSLionel Sambuc     void dr29_f6(); // ok, g6 is extern "C" but we're not inside the linkage-specification here.
342f4a2713aSLionel Sambuc   }
343f4a2713aSLionel Sambuc 
344f4a2713aSLionel Sambuc   extern "C" void g7();
345f4a2713aSLionel Sambuc   extern "C++" void dr29_f7(); // expected-note {{here}}
g7()346f4a2713aSLionel Sambuc   extern "C" void g7() {
347f4a2713aSLionel Sambuc     void dr29_f7(); // expected-error {{different language linkage}}
348f4a2713aSLionel Sambuc   }
349f4a2713aSLionel Sambuc 
350f4a2713aSLionel Sambuc   extern "C++" void g8();
351f4a2713aSLionel Sambuc   extern "C" void dr29_f8(); // expected-note {{here}}
g8()352f4a2713aSLionel Sambuc   extern "C++" void g8() {
353f4a2713aSLionel Sambuc     void dr29_f8(); // expected-error {{different language linkage}}
354f4a2713aSLionel Sambuc   }
355f4a2713aSLionel Sambuc }
356f4a2713aSLionel Sambuc 
357f4a2713aSLionel Sambuc namespace dr30 { // dr30: sup 468 c++11
358f4a2713aSLionel Sambuc   struct A {
359f4a2713aSLionel Sambuc     template<int> static int f();
360f4a2713aSLionel Sambuc   } a, *p = &a;
361f4a2713aSLionel Sambuc   int x = A::template f<0>();
362f4a2713aSLionel Sambuc   int y = a.template f<0>();
363f4a2713aSLionel Sambuc   int z = p->template f<0>();
364f4a2713aSLionel Sambuc #if __cplusplus < 201103L
365f4a2713aSLionel Sambuc   // FIXME: It's not clear whether DR468 applies to C++98 too.
366f4a2713aSLionel Sambuc   // expected-error@-5 {{'template' keyword outside of a template}}
367f4a2713aSLionel Sambuc   // expected-error@-5 {{'template' keyword outside of a template}}
368f4a2713aSLionel Sambuc   // expected-error@-5 {{'template' keyword outside of a template}}
369f4a2713aSLionel Sambuc #endif
370f4a2713aSLionel Sambuc }
371f4a2713aSLionel Sambuc 
372f4a2713aSLionel Sambuc namespace dr31 { // dr31: yes
373f4a2713aSLionel Sambuc   class X {
374f4a2713aSLionel Sambuc   private:
375f4a2713aSLionel Sambuc     void operator delete(void*); // expected-note {{here}}
376f4a2713aSLionel Sambuc   };
377f4a2713aSLionel Sambuc   // We would call X::operator delete if X() threw (even though it can't,
378f4a2713aSLionel Sambuc   // and even though we allocated the X using ::operator delete).
379f4a2713aSLionel Sambuc   X *p = new X; // expected-error {{private}}
380f4a2713aSLionel Sambuc }
381f4a2713aSLionel Sambuc 
382f4a2713aSLionel Sambuc // dr32: na
383f4a2713aSLionel Sambuc 
384f4a2713aSLionel Sambuc namespace dr33 { // dr33: yes
385f4a2713aSLionel Sambuc   namespace X { struct S; void f(void (*)(S)); } // expected-note {{candidate}}
386f4a2713aSLionel Sambuc   namespace Y { struct T; void f(void (*)(T)); } // expected-note {{candidate}}
387f4a2713aSLionel Sambuc   void g(X::S);
388f4a2713aSLionel Sambuc   template<typename Z> Z g(Y::T);
h()389f4a2713aSLionel Sambuc   void h() { f(&g); } // expected-error {{ambiguous}}
390f4a2713aSLionel Sambuc }
391f4a2713aSLionel Sambuc 
392f4a2713aSLionel Sambuc // dr34: na
393f4a2713aSLionel Sambuc // dr35: dup 178
394f4a2713aSLionel Sambuc // dr37: sup 475
395f4a2713aSLionel Sambuc 
396f4a2713aSLionel Sambuc namespace dr38 { // dr38: yes
397f4a2713aSLionel Sambuc   template<typename T> struct X {};
operator +(X<T> a,X<T> b)398f4a2713aSLionel Sambuc   template<typename T> X<T> operator+(X<T> a, X<T> b) { return a; }
399f4a2713aSLionel Sambuc   template X<int> operator+<int>(X<int>, X<int>);
400f4a2713aSLionel Sambuc }
401f4a2713aSLionel Sambuc 
402f4a2713aSLionel Sambuc namespace dr39 { // dr39: no
403f4a2713aSLionel Sambuc   namespace example1 {
404f4a2713aSLionel Sambuc     struct A { int &f(int); };
405f4a2713aSLionel Sambuc     struct B : A {
406f4a2713aSLionel Sambuc       using A::f;
407f4a2713aSLionel Sambuc       float &f(float);
408f4a2713aSLionel Sambuc     } b;
409f4a2713aSLionel Sambuc     int &r = b.f(0);
410f4a2713aSLionel Sambuc   }
411f4a2713aSLionel Sambuc 
412f4a2713aSLionel Sambuc   namespace example2 {
413f4a2713aSLionel Sambuc     struct A {
414f4a2713aSLionel Sambuc       int &x(int); // expected-note {{found}}
415f4a2713aSLionel Sambuc       static int &y(int); // expected-note {{found}}
416f4a2713aSLionel Sambuc     };
417f4a2713aSLionel Sambuc     struct V {
418f4a2713aSLionel Sambuc       int &z(int);
419f4a2713aSLionel Sambuc     };
420f4a2713aSLionel Sambuc     struct B : A, virtual V {
421f4a2713aSLionel Sambuc       using A::x; // expected-note {{found}}
422f4a2713aSLionel Sambuc       float &x(float);
423f4a2713aSLionel Sambuc       using A::y; // expected-note {{found}}
424f4a2713aSLionel Sambuc       static float &y(float);
425f4a2713aSLionel Sambuc       using V::z;
426f4a2713aSLionel Sambuc       float &z(float);
427f4a2713aSLionel Sambuc     };
428f4a2713aSLionel Sambuc     struct C : A, B, virtual V {} c;
429f4a2713aSLionel Sambuc     int &x = c.x(0); // expected-error {{found in multiple base classes}}
430f4a2713aSLionel Sambuc     // FIXME: This is valid, because we find the same static data member either way.
431f4a2713aSLionel Sambuc     int &y = c.y(0); // expected-error {{found in multiple base classes}}
432f4a2713aSLionel Sambuc     int &z = c.z(0);
433f4a2713aSLionel Sambuc   }
434f4a2713aSLionel Sambuc 
435f4a2713aSLionel Sambuc   namespace example3 {
436f4a2713aSLionel Sambuc     struct A { static int f(); };
437f4a2713aSLionel Sambuc     struct B : virtual A { using A::f; };
438f4a2713aSLionel Sambuc     struct C : virtual A { using A::f; };
439f4a2713aSLionel Sambuc     struct D : B, C {} d;
440f4a2713aSLionel Sambuc     int k = d.f();
441f4a2713aSLionel Sambuc   }
442f4a2713aSLionel Sambuc 
443f4a2713aSLionel Sambuc   namespace example4 {
444f4a2713aSLionel Sambuc     struct A { int n; }; // expected-note {{found}}
445f4a2713aSLionel Sambuc     struct B : A {};
446f4a2713aSLionel Sambuc     struct C : A {};
fdr39::example4::D447f4a2713aSLionel Sambuc     struct D : B, C { int f() { return n; } }; // expected-error {{found in multiple base-class}}
448f4a2713aSLionel Sambuc   }
449f4a2713aSLionel Sambuc 
450f4a2713aSLionel Sambuc   namespace PR5916 {
451f4a2713aSLionel Sambuc     // FIXME: This is valid.
452f4a2713aSLionel Sambuc     struct A { int n; }; // expected-note +{{found}}
453f4a2713aSLionel Sambuc     struct B : A {};
454f4a2713aSLionel Sambuc     struct C : A {};
455f4a2713aSLionel Sambuc     struct D : B, C {};
456f4a2713aSLionel Sambuc     int k = sizeof(D::n); // expected-error {{found in multiple base}} expected-error {{unknown type name}}
457f4a2713aSLionel Sambuc #if __cplusplus >= 201103L
458f4a2713aSLionel Sambuc     decltype(D::n) n; // expected-error {{found in multiple base}}
459f4a2713aSLionel Sambuc #endif
460f4a2713aSLionel Sambuc   }
461f4a2713aSLionel Sambuc }
462f4a2713aSLionel Sambuc 
463f4a2713aSLionel Sambuc // dr40: na
464f4a2713aSLionel Sambuc 
465f4a2713aSLionel Sambuc namespace dr41 { // dr41: yes
466f4a2713aSLionel Sambuc   struct S f(S);
467f4a2713aSLionel Sambuc }
468f4a2713aSLionel Sambuc 
469f4a2713aSLionel Sambuc namespace dr42 { // dr42: yes
470f4a2713aSLionel Sambuc   struct A { static const int k = 0; };
471f4a2713aSLionel Sambuc   struct B : A { static const int k = A::k; };
472f4a2713aSLionel Sambuc }
473f4a2713aSLionel Sambuc 
474f4a2713aSLionel Sambuc // dr43: na
475f4a2713aSLionel Sambuc 
476f4a2713aSLionel Sambuc namespace dr44 { // dr44: yes
477f4a2713aSLionel Sambuc   struct A {
478f4a2713aSLionel Sambuc     template<int> void f();
479f4a2713aSLionel Sambuc     template<> void f<0>(); // expected-error {{explicit specialization of 'f' in class scope}}
480f4a2713aSLionel Sambuc   };
481f4a2713aSLionel Sambuc }
482f4a2713aSLionel Sambuc 
483f4a2713aSLionel Sambuc namespace dr45 { // dr45: yes
484f4a2713aSLionel Sambuc   class A {
485f4a2713aSLionel Sambuc     class B {};
486f4a2713aSLionel Sambuc     class C : B {};
487f4a2713aSLionel Sambuc     C c;
488f4a2713aSLionel Sambuc   };
489f4a2713aSLionel Sambuc }
490f4a2713aSLionel Sambuc 
491f4a2713aSLionel Sambuc namespace dr46 { // dr46: yes
492f4a2713aSLionel Sambuc   template<typename> struct A { template<typename> struct B {}; };
493f4a2713aSLionel Sambuc   template template struct A<int>::B<int>; // expected-error {{expected unqualified-id}}
494f4a2713aSLionel Sambuc }
495f4a2713aSLionel Sambuc 
496*0a6a1f1dSLionel Sambuc namespace dr47 { // dr47: sup 329
497f4a2713aSLionel Sambuc   template<typename T> struct A {
f()498*0a6a1f1dSLionel Sambuc     friend void f() { T t; } // expected-error {{redefinition}} expected-note {{previous}}
499f4a2713aSLionel Sambuc   };
500f4a2713aSLionel Sambuc   A<int> a;
501*0a6a1f1dSLionel Sambuc   A<float> b; // expected-note {{instantiation of}}
502*0a6a1f1dSLionel Sambuc 
503f4a2713aSLionel Sambuc   void f();
g()504f4a2713aSLionel Sambuc   void g() { f(); }
505f4a2713aSLionel Sambuc }
506f4a2713aSLionel Sambuc 
507f4a2713aSLionel Sambuc namespace dr48 { // dr48: yes
508f4a2713aSLionel Sambuc   namespace {
509f4a2713aSLionel Sambuc     struct S {
510f4a2713aSLionel Sambuc       static const int m = 0;
511f4a2713aSLionel Sambuc       static const int n = 0;
512f4a2713aSLionel Sambuc       static const int o = 0;
513f4a2713aSLionel Sambuc     };
514f4a2713aSLionel Sambuc   }
515f4a2713aSLionel Sambuc   int a = S::m;
516f4a2713aSLionel Sambuc   // FIXME: We should produce a 'has internal linkage but is not defined'
517f4a2713aSLionel Sambuc   // diagnostic for 'S::n'.
518f4a2713aSLionel Sambuc   const int &b = S::n;
519f4a2713aSLionel Sambuc   const int S::o;
520f4a2713aSLionel Sambuc   const int &c = S::o;
521f4a2713aSLionel Sambuc }
522f4a2713aSLionel Sambuc 
523f4a2713aSLionel Sambuc namespace dr49 { // dr49: yes
524*0a6a1f1dSLionel Sambuc   template<int*> struct A {}; // expected-note 0-2{{here}}
525f4a2713aSLionel Sambuc   int k;
526f4a2713aSLionel Sambuc #if __has_feature(cxx_constexpr)
527f4a2713aSLionel Sambuc   constexpr
528f4a2713aSLionel Sambuc #endif
529*0a6a1f1dSLionel Sambuc   int *const p = &k; // expected-note 0-2{{here}}
530f4a2713aSLionel Sambuc   A<&k> a;
531*0a6a1f1dSLionel Sambuc   A<p> b;
532*0a6a1f1dSLionel Sambuc #if __cplusplus <= 201402L
533*0a6a1f1dSLionel Sambuc   // expected-error@-2 {{must have its address taken}}
534*0a6a1f1dSLionel Sambuc #endif
535f4a2713aSLionel Sambuc #if __cplusplus < 201103L
536*0a6a1f1dSLionel Sambuc   // expected-error@-5 {{internal linkage}}
537*0a6a1f1dSLionel Sambuc #endif
538*0a6a1f1dSLionel Sambuc   int *q = &k;
539*0a6a1f1dSLionel Sambuc   A<q> c;
540*0a6a1f1dSLionel Sambuc #if __cplusplus < 201103L
541*0a6a1f1dSLionel Sambuc   // expected-error@-2 {{must have its address taken}}
542*0a6a1f1dSLionel Sambuc #else
543*0a6a1f1dSLionel Sambuc   // expected-error@-4 {{constant expression}}
544*0a6a1f1dSLionel Sambuc   // expected-note@-5 {{read of non-constexpr}}
545*0a6a1f1dSLionel Sambuc   // expected-note@-7 {{declared here}}
546f4a2713aSLionel Sambuc #endif
547f4a2713aSLionel Sambuc }
548f4a2713aSLionel Sambuc 
549f4a2713aSLionel Sambuc namespace dr50 { // dr50: yes
550f4a2713aSLionel Sambuc   struct X; // expected-note {{forward}}
551f4a2713aSLionel Sambuc   extern X *p;
552f4a2713aSLionel Sambuc   X *q = (X*)p;
553f4a2713aSLionel Sambuc   X *r = static_cast<X*>(p);
554f4a2713aSLionel Sambuc   X *s = const_cast<X*>(p);
555f4a2713aSLionel Sambuc   X *t = reinterpret_cast<X*>(p);
556f4a2713aSLionel Sambuc   X *u = dynamic_cast<X*>(p); // expected-error {{incomplete}}
557f4a2713aSLionel Sambuc }
558f4a2713aSLionel Sambuc 
559f4a2713aSLionel Sambuc namespace dr51 { // dr51: yes
560f4a2713aSLionel Sambuc   struct A {};
561f4a2713aSLionel Sambuc   struct B : A {};
562f4a2713aSLionel Sambuc   struct S {
563f4a2713aSLionel Sambuc     operator A&();
564f4a2713aSLionel Sambuc     operator B&();
565f4a2713aSLionel Sambuc   } s;
566f4a2713aSLionel Sambuc   A &a = s;
567f4a2713aSLionel Sambuc }
568f4a2713aSLionel Sambuc 
569f4a2713aSLionel Sambuc namespace dr52 { // dr52: yes
570f4a2713aSLionel Sambuc   struct A { int n; }; // expected-note {{here}}
571f4a2713aSLionel Sambuc   struct B : private A {} b; // expected-note 2{{private}}
572f4a2713aSLionel Sambuc   // FIXME: This first diagnostic is very strangely worded, and seems to be bogus.
573f4a2713aSLionel Sambuc   int k = b.A::n; // expected-error {{'A' is a private member of 'dr52::A'}}
574f4a2713aSLionel Sambuc   // expected-error@-1 {{cannot cast 'struct B' to its private base}}
575f4a2713aSLionel Sambuc }
576f4a2713aSLionel Sambuc 
577f4a2713aSLionel Sambuc namespace dr53 { // dr53: yes
578f4a2713aSLionel Sambuc   int n = 0;
579f4a2713aSLionel Sambuc   enum E { e } x = static_cast<E>(n);
580f4a2713aSLionel Sambuc }
581f4a2713aSLionel Sambuc 
582f4a2713aSLionel Sambuc namespace dr54 { // dr54: yes
583f4a2713aSLionel Sambuc   struct A { int a; } a;
584f4a2713aSLionel Sambuc   struct V { int v; } v;
585f4a2713aSLionel Sambuc   struct B : private A, virtual V { int b; } b; // expected-note 6{{private here}}
586f4a2713aSLionel Sambuc 
587f4a2713aSLionel Sambuc   A &sab = static_cast<A&>(b); // expected-error {{private base}}
588f4a2713aSLionel Sambuc   A *spab = static_cast<A*>(&b); // expected-error {{private base}}
589f4a2713aSLionel Sambuc   int A::*smab = static_cast<int A::*>(&B::b); // expected-error {{private base}}
590f4a2713aSLionel Sambuc   B &sba = static_cast<B&>(a); // expected-error {{private base}}
591f4a2713aSLionel Sambuc   B *spba = static_cast<B*>(&a); // expected-error {{private base}}
592f4a2713aSLionel Sambuc   int B::*smba = static_cast<int B::*>(&A::a); // expected-error {{private base}}
593f4a2713aSLionel Sambuc 
594f4a2713aSLionel Sambuc   V &svb = static_cast<V&>(b);
595f4a2713aSLionel Sambuc   V *spvb = static_cast<V*>(&b);
596f4a2713aSLionel Sambuc   int V::*smvb = static_cast<int V::*>(&B::b); // expected-error {{virtual base}}
597f4a2713aSLionel Sambuc   B &sbv = static_cast<B&>(v); // expected-error {{virtual base}}
598f4a2713aSLionel Sambuc   B *spbv = static_cast<B*>(&v); // expected-error {{virtual base}}
599f4a2713aSLionel Sambuc   int B::*smbv = static_cast<int B::*>(&V::v); // expected-error {{virtual base}}
600f4a2713aSLionel Sambuc 
601f4a2713aSLionel Sambuc   A &cab = (A&)(b);
602f4a2713aSLionel Sambuc   A *cpab = (A*)(&b);
603f4a2713aSLionel Sambuc   int A::*cmab = (int A::*)(&B::b);
604f4a2713aSLionel Sambuc   B &cba = (B&)(a);
605f4a2713aSLionel Sambuc   B *cpba = (B*)(&a);
606f4a2713aSLionel Sambuc   int B::*cmba = (int B::*)(&A::a);
607f4a2713aSLionel Sambuc 
608f4a2713aSLionel Sambuc   V &cvb = (V&)(b);
609f4a2713aSLionel Sambuc   V *cpvb = (V*)(&b);
610f4a2713aSLionel Sambuc   int V::*cmvb = (int V::*)(&B::b); // expected-error {{virtual base}}
611f4a2713aSLionel Sambuc   B &cbv = (B&)(v); // expected-error {{virtual base}}
612f4a2713aSLionel Sambuc   B *cpbv = (B*)(&v); // expected-error {{virtual base}}
613f4a2713aSLionel Sambuc   int B::*cmbv = (int B::*)(&V::v); // expected-error {{virtual base}}
614f4a2713aSLionel Sambuc }
615f4a2713aSLionel Sambuc 
616f4a2713aSLionel Sambuc namespace dr55 { // dr55: yes
617f4a2713aSLionel Sambuc   enum E { e = 5 };
618f4a2713aSLionel Sambuc   int test[(e + 1 == 6) ? 1 : -1];
619f4a2713aSLionel Sambuc }
620f4a2713aSLionel Sambuc 
621f4a2713aSLionel Sambuc namespace dr56 { // dr56: yes
622f4a2713aSLionel Sambuc   struct A {
623f4a2713aSLionel Sambuc     typedef int T; // expected-note {{previous}}
624f4a2713aSLionel Sambuc     typedef int T; // expected-error {{redefinition}}
625f4a2713aSLionel Sambuc   };
626f4a2713aSLionel Sambuc   struct B {
627f4a2713aSLionel Sambuc     struct X;
628f4a2713aSLionel Sambuc     typedef X X; // expected-note {{previous}}
629f4a2713aSLionel Sambuc     typedef X X; // expected-error {{redefinition}}
630f4a2713aSLionel Sambuc   };
631f4a2713aSLionel Sambuc }
632f4a2713aSLionel Sambuc 
633f4a2713aSLionel Sambuc namespace dr58 { // dr58: yes
634f4a2713aSLionel Sambuc   // FIXME: Ideally, we should have a CodeGen test for this.
635f4a2713aSLionel Sambuc #if __cplusplus >= 201103L
636f4a2713aSLionel Sambuc   enum E1 { E1_0 = 0, E1_1 = 1 };
637f4a2713aSLionel Sambuc   enum E2 { E2_0 = 0, E2_m1 = -1 };
638f4a2713aSLionel Sambuc   struct X { E1 e1 : 1; E2 e2 : 1; };
639f4a2713aSLionel Sambuc   static_assert(X{E1_1, E2_m1}.e1 == 1, "");
640f4a2713aSLionel Sambuc   static_assert(X{E1_1, E2_m1}.e2 == -1, "");
641f4a2713aSLionel Sambuc #endif
642f4a2713aSLionel Sambuc }
643f4a2713aSLionel Sambuc 
644f4a2713aSLionel Sambuc namespace dr59 { // dr59: yes
645f4a2713aSLionel Sambuc   template<typename T> struct convert_to { operator T() const; };
646f4a2713aSLionel Sambuc   struct A {}; // expected-note 2{{volatile qualifier}}
647f4a2713aSLionel Sambuc   struct B : A {}; // expected-note 2{{volatile qualifier}}
648f4a2713aSLionel Sambuc #if __cplusplus >= 201103L // move constructors
649f4a2713aSLionel Sambuc   // expected-note@-3 2{{volatile qualifier}}
650f4a2713aSLionel Sambuc   // expected-note@-3 2{{volatile qualifier}}
651f4a2713aSLionel Sambuc #endif
652f4a2713aSLionel Sambuc 
653f4a2713aSLionel Sambuc   A a1 = convert_to<A>();
654f4a2713aSLionel Sambuc   A a2 = convert_to<A&>();
655f4a2713aSLionel Sambuc   A a3 = convert_to<const A>();
656f4a2713aSLionel Sambuc   A a4 = convert_to<const volatile A>(); // expected-error {{no viable}}
657f4a2713aSLionel Sambuc   A a5 = convert_to<const volatile A&>(); // expected-error {{no viable}}
658f4a2713aSLionel Sambuc 
659f4a2713aSLionel Sambuc   B b1 = convert_to<B>();
660f4a2713aSLionel Sambuc   B b2 = convert_to<B&>();
661f4a2713aSLionel Sambuc   B b3 = convert_to<const B>();
662f4a2713aSLionel Sambuc   B b4 = convert_to<const volatile B>(); // expected-error {{no viable}}
663f4a2713aSLionel Sambuc   B b5 = convert_to<const volatile B&>(); // expected-error {{no viable}}
664f4a2713aSLionel Sambuc 
665f4a2713aSLionel Sambuc   int n1 = convert_to<int>();
666f4a2713aSLionel Sambuc   int n2 = convert_to<int&>();
667f4a2713aSLionel Sambuc   int n3 = convert_to<const int>();
668f4a2713aSLionel Sambuc   int n4 = convert_to<const volatile int>();
669f4a2713aSLionel Sambuc   int n5 = convert_to<const volatile int&>();
670f4a2713aSLionel Sambuc }
671f4a2713aSLionel Sambuc 
672f4a2713aSLionel Sambuc namespace dr60 { // dr60: yes
673f4a2713aSLionel Sambuc   void f(int &);
674f4a2713aSLionel Sambuc   int &f(...);
675f4a2713aSLionel Sambuc   const int k = 0;
676f4a2713aSLionel Sambuc   int &n = f(k);
677f4a2713aSLionel Sambuc }
678f4a2713aSLionel Sambuc 
679f4a2713aSLionel Sambuc namespace dr61 { // dr61: yes
680f4a2713aSLionel Sambuc   struct X {
681f4a2713aSLionel Sambuc     static void f();
682f4a2713aSLionel Sambuc   } x;
683f4a2713aSLionel Sambuc   struct Y {
684f4a2713aSLionel Sambuc     static void f();
685f4a2713aSLionel Sambuc     static void f(int);
686f4a2713aSLionel Sambuc   } y;
687f4a2713aSLionel Sambuc   // This is (presumably) valid, because x.f does not refer to an overloaded
688f4a2713aSLionel Sambuc   // function name.
689f4a2713aSLionel Sambuc   void (*p)() = &x.f;
690f4a2713aSLionel Sambuc   void (*q)() = &y.f; // expected-error {{cannot create a non-constant pointer to member function}}
691f4a2713aSLionel Sambuc   void (*r)() = y.f; // expected-error {{cannot create a non-constant pointer to member function}}
692f4a2713aSLionel Sambuc }
693f4a2713aSLionel Sambuc 
694f4a2713aSLionel Sambuc namespace dr62 { // dr62: yes
695f4a2713aSLionel Sambuc   struct A {
696f4a2713aSLionel Sambuc     struct { int n; } b;
697f4a2713aSLionel Sambuc   };
698f4a2713aSLionel Sambuc   template<typename T> struct X {};
get()699f4a2713aSLionel Sambuc   template<typename T> T get() { return get<T>(); }
take(T)700f4a2713aSLionel Sambuc   template<typename T> int take(T) { return 0; }
701f4a2713aSLionel Sambuc 
702f4a2713aSLionel Sambuc   X<A> x1;
703f4a2713aSLionel Sambuc   A a = get<A>();
704f4a2713aSLionel Sambuc 
705f4a2713aSLionel Sambuc   typedef struct { } *NoNameForLinkagePtr;
706f4a2713aSLionel Sambuc #if __cplusplus < 201103L
707f4a2713aSLionel Sambuc   // expected-note@-2 5{{here}}
708f4a2713aSLionel Sambuc #endif
709f4a2713aSLionel Sambuc   NoNameForLinkagePtr noNameForLinkagePtr;
710f4a2713aSLionel Sambuc 
711f4a2713aSLionel Sambuc   struct Danger {
712f4a2713aSLionel Sambuc     NoNameForLinkagePtr p;
713f4a2713aSLionel Sambuc   };
714f4a2713aSLionel Sambuc 
715f4a2713aSLionel Sambuc   X<NoNameForLinkagePtr> x2;
716f4a2713aSLionel Sambuc   X<const NoNameForLinkagePtr> x3;
717f4a2713aSLionel Sambuc   NoNameForLinkagePtr p1 = get<NoNameForLinkagePtr>();
718f4a2713aSLionel Sambuc   NoNameForLinkagePtr p2 = get<const NoNameForLinkagePtr>();
719f4a2713aSLionel Sambuc   int n1 = take(noNameForLinkagePtr);
720f4a2713aSLionel Sambuc #if __cplusplus < 201103L
721f4a2713aSLionel Sambuc   // expected-error@-6 {{uses unnamed type}}
722f4a2713aSLionel Sambuc   // expected-error@-6 {{uses unnamed type}}
723f4a2713aSLionel Sambuc   // expected-error@-6 {{uses unnamed type}}
724f4a2713aSLionel Sambuc   // expected-error@-6 {{uses unnamed type}}
725f4a2713aSLionel Sambuc   // expected-error@-6 {{uses unnamed type}}
726f4a2713aSLionel Sambuc #endif
727f4a2713aSLionel Sambuc 
728f4a2713aSLionel Sambuc   X<Danger> x4;
729f4a2713aSLionel Sambuc 
f()730f4a2713aSLionel Sambuc   void f() {
731f4a2713aSLionel Sambuc     struct NoLinkage {};
732f4a2713aSLionel Sambuc     X<NoLinkage> a;
733f4a2713aSLionel Sambuc     X<const NoLinkage> b;
734f4a2713aSLionel Sambuc     get<NoLinkage>();
735f4a2713aSLionel Sambuc     get<const NoLinkage>();
736f4a2713aSLionel Sambuc     X<void (*)(NoLinkage A::*)> c;
737f4a2713aSLionel Sambuc     X<int NoLinkage::*> d;
738f4a2713aSLionel Sambuc #if __cplusplus < 201103L
739f4a2713aSLionel Sambuc   // expected-error@-7 {{uses local type}}
740f4a2713aSLionel Sambuc   // expected-error@-7 {{uses local type}}
741f4a2713aSLionel Sambuc   // expected-error@-7 {{uses local type}}
742f4a2713aSLionel Sambuc   // expected-error@-7 {{uses local type}}
743f4a2713aSLionel Sambuc   // expected-error@-7 {{uses local type}}
744f4a2713aSLionel Sambuc   // expected-error@-7 {{uses local type}}
745f4a2713aSLionel Sambuc #endif
746f4a2713aSLionel Sambuc   }
747f4a2713aSLionel Sambuc }
748f4a2713aSLionel Sambuc 
749f4a2713aSLionel Sambuc namespace dr63 { // dr63: yes
750f4a2713aSLionel Sambuc   template<typename T> struct S { typename T::error e; };
751f4a2713aSLionel Sambuc   extern S<int> *p;
752f4a2713aSLionel Sambuc   void *q = p;
753f4a2713aSLionel Sambuc }
754f4a2713aSLionel Sambuc 
755f4a2713aSLionel Sambuc namespace dr64 { // dr64: yes
756f4a2713aSLionel Sambuc   template<class T> void f(T);
757f4a2713aSLionel Sambuc   template<class T> void f(T*);
758f4a2713aSLionel Sambuc   template<> void f(int*);
759f4a2713aSLionel Sambuc   template<> void f<int>(int*);
760f4a2713aSLionel Sambuc   template<> void f(int);
761f4a2713aSLionel Sambuc }
762f4a2713aSLionel Sambuc 
763f4a2713aSLionel Sambuc // dr65: na
764f4a2713aSLionel Sambuc 
765f4a2713aSLionel Sambuc namespace dr66 { // dr66: no
766f4a2713aSLionel Sambuc   namespace X {
767f4a2713aSLionel Sambuc     int f(int n); // expected-note 2{{candidate}}
768f4a2713aSLionel Sambuc   }
769f4a2713aSLionel Sambuc   using X::f;
770f4a2713aSLionel Sambuc   namespace X {
771f4a2713aSLionel Sambuc     int f(int n = 0);
772f4a2713aSLionel Sambuc     int f(int, int);
773f4a2713aSLionel Sambuc   }
774f4a2713aSLionel Sambuc   // FIXME: The first two calls here should be accepted.
775f4a2713aSLionel Sambuc   int a = f(); // expected-error {{no matching function}}
776f4a2713aSLionel Sambuc   int b = f(1);
777f4a2713aSLionel Sambuc   int c = f(1, 2); // expected-error {{no matching function}}
778f4a2713aSLionel Sambuc }
779f4a2713aSLionel Sambuc 
780f4a2713aSLionel Sambuc // dr67: na
781f4a2713aSLionel Sambuc 
782f4a2713aSLionel Sambuc namespace dr68 { // dr68: yes
783f4a2713aSLionel Sambuc   template<typename T> struct X {};
784f4a2713aSLionel Sambuc   struct ::dr68::X<int> x1;
785f4a2713aSLionel Sambuc   struct ::dr68::template X<int> x2;
786f4a2713aSLionel Sambuc #if __cplusplus < 201103L
787f4a2713aSLionel Sambuc   // expected-error@-2 {{'template' keyword outside of a template}}
788f4a2713aSLionel Sambuc #endif
789f4a2713aSLionel Sambuc   struct Y {
790f4a2713aSLionel Sambuc     friend struct X<int>;
791f4a2713aSLionel Sambuc     friend struct ::dr68::X<char>;
792f4a2713aSLionel Sambuc     friend struct ::dr68::template X<double>;
793f4a2713aSLionel Sambuc #if __cplusplus < 201103L
794f4a2713aSLionel Sambuc   // expected-error@-2 {{'template' keyword outside of a template}}
795f4a2713aSLionel Sambuc #endif
796f4a2713aSLionel Sambuc   };
797f4a2713aSLionel Sambuc   template<typename>
798f4a2713aSLionel Sambuc   struct Z {
799f4a2713aSLionel Sambuc     friend struct ::dr68::template X<double>;
800f4a2713aSLionel Sambuc     friend typename ::dr68::X<double>;
801f4a2713aSLionel Sambuc #if __cplusplus < 201103L
802f4a2713aSLionel Sambuc   // expected-error@-2 {{C++11 extension}}
803f4a2713aSLionel Sambuc #endif
804f4a2713aSLionel Sambuc   };
805f4a2713aSLionel Sambuc }
806f4a2713aSLionel Sambuc 
807f4a2713aSLionel Sambuc namespace dr69 { // dr69: yes
f()808f4a2713aSLionel Sambuc   template<typename T> static void f() {}
809f4a2713aSLionel Sambuc   // FIXME: Should we warn here?
g()810f4a2713aSLionel Sambuc   inline void g() { f<int>(); }
811f4a2713aSLionel Sambuc   // FIXME: This should be rejected, per [temp.explicit]p11.
812f4a2713aSLionel Sambuc   extern template void f<char>();
813f4a2713aSLionel Sambuc #if __cplusplus < 201103L
814f4a2713aSLionel Sambuc   // expected-error@-2 {{C++11 extension}}
815f4a2713aSLionel Sambuc #endif
816f4a2713aSLionel Sambuc   template<void(*)()> struct Q {};
817f4a2713aSLionel Sambuc   Q<&f<int> > q;
818f4a2713aSLionel Sambuc #if __cplusplus < 201103L
819f4a2713aSLionel Sambuc   // expected-error@-2 {{internal linkage}} expected-note@-11 {{here}}
820f4a2713aSLionel Sambuc #endif
821f4a2713aSLionel Sambuc }
822f4a2713aSLionel Sambuc 
823f4a2713aSLionel Sambuc namespace dr70 { // dr70: yes
824f4a2713aSLionel Sambuc   template<int> struct A {};
825f4a2713aSLionel Sambuc   template<int I, int J> int f(int (&)[I + J], A<I>, A<J>);
826f4a2713aSLionel Sambuc   int arr[7];
827f4a2713aSLionel Sambuc   int k = f(arr, A<3>(), A<4>());
828f4a2713aSLionel Sambuc }
829f4a2713aSLionel Sambuc 
830f4a2713aSLionel Sambuc // dr71: na
831f4a2713aSLionel Sambuc // dr72: dup 69
832f4a2713aSLionel Sambuc 
833f4a2713aSLionel Sambuc #if __cplusplus >= 201103L
834f4a2713aSLionel Sambuc namespace dr73 { // dr73: no
835f4a2713aSLionel Sambuc   // The resolution to dr73 is unworkable. Consider:
836f4a2713aSLionel Sambuc   int a, b;
837*0a6a1f1dSLionel Sambuc   static_assert(&a + 1 != &b, ""); // expected-error {{not an integral constant expression}}
838f4a2713aSLionel Sambuc }
839f4a2713aSLionel Sambuc #endif
840f4a2713aSLionel Sambuc 
841f4a2713aSLionel Sambuc namespace dr74 { // dr74: yes
842f4a2713aSLionel Sambuc   enum E { k = 5 };
843f4a2713aSLionel Sambuc   int (*p)[k] = new int[k][k];
844f4a2713aSLionel Sambuc }
845f4a2713aSLionel Sambuc 
846f4a2713aSLionel Sambuc namespace dr75 { // dr75: yes
847f4a2713aSLionel Sambuc   struct S {
848f4a2713aSLionel Sambuc     static int n = 0; // expected-error {{non-const}}
849f4a2713aSLionel Sambuc   };
850f4a2713aSLionel Sambuc }
851f4a2713aSLionel Sambuc 
852f4a2713aSLionel Sambuc namespace dr76 { // dr76: yes
853f4a2713aSLionel Sambuc   const volatile int n = 1;
854f4a2713aSLionel Sambuc   int arr[n]; // expected-error +{{variable length array}}
855f4a2713aSLionel Sambuc }
856f4a2713aSLionel Sambuc 
857f4a2713aSLionel Sambuc namespace dr77 { // dr77: yes
858f4a2713aSLionel Sambuc   struct A {
859f4a2713aSLionel Sambuc     struct B {};
860f4a2713aSLionel Sambuc     friend struct B;
861f4a2713aSLionel Sambuc   };
862f4a2713aSLionel Sambuc }
863f4a2713aSLionel Sambuc 
864f4a2713aSLionel Sambuc namespace dr78 { // dr78: sup ????
865f4a2713aSLionel Sambuc   // Under DR78, this is valid, because 'k' has static storage duration, so is
866f4a2713aSLionel Sambuc   // zero-initialized.
867*0a6a1f1dSLionel Sambuc   const int k; // expected-error {{default initialization of an object of const}} expected-note{{add an explicit initializer to initialize 'k'}}
868f4a2713aSLionel Sambuc }
869f4a2713aSLionel Sambuc 
870f4a2713aSLionel Sambuc // dr79: na
871f4a2713aSLionel Sambuc 
872f4a2713aSLionel Sambuc namespace dr80 { // dr80: yes
873f4a2713aSLionel Sambuc   struct A {
874f4a2713aSLionel Sambuc     int A;
875f4a2713aSLionel Sambuc   };
876f4a2713aSLionel Sambuc   struct B {
877f4a2713aSLionel Sambuc     static int B; // expected-error {{same name as its class}}
878f4a2713aSLionel Sambuc   };
879f4a2713aSLionel Sambuc   struct C {
880f4a2713aSLionel Sambuc     int C; // expected-note {{hidden by}}
881f4a2713aSLionel Sambuc     // FIXME: These diagnostics aren't very good.
882f4a2713aSLionel Sambuc     C(); // expected-error {{must use 'struct' tag to refer to}} expected-error {{expected member name}}
883f4a2713aSLionel Sambuc   };
884f4a2713aSLionel Sambuc   struct D {
885f4a2713aSLionel Sambuc     D();
886f4a2713aSLionel Sambuc     int D; // expected-error {{same name as its class}}
887f4a2713aSLionel Sambuc   };
888f4a2713aSLionel Sambuc }
889f4a2713aSLionel Sambuc 
890f4a2713aSLionel Sambuc // dr81: na
891f4a2713aSLionel Sambuc // dr82: dup 48
892f4a2713aSLionel Sambuc 
893f4a2713aSLionel Sambuc namespace dr83 { // dr83: yes
894f4a2713aSLionel Sambuc   int &f(const char*);
895f4a2713aSLionel Sambuc   char &f(char *);
896f4a2713aSLionel Sambuc   int &k = f("foo");
897f4a2713aSLionel Sambuc }
898f4a2713aSLionel Sambuc 
899f4a2713aSLionel Sambuc namespace dr84 { // dr84: yes
900f4a2713aSLionel Sambuc   struct B;
901f4a2713aSLionel Sambuc   struct A { operator B() const; };
902f4a2713aSLionel Sambuc   struct C {};
903f4a2713aSLionel Sambuc   struct B {
904f4a2713aSLionel Sambuc     B(B&); // expected-note {{candidate}}
905f4a2713aSLionel Sambuc     B(C);
906f4a2713aSLionel Sambuc     operator C() const;
907f4a2713aSLionel Sambuc   };
908f4a2713aSLionel Sambuc   A a;
909f4a2713aSLionel Sambuc   // Cannot use B(C) / operator C() pair to construct the B from the B temporary
910f4a2713aSLionel Sambuc   // here.
911f4a2713aSLionel Sambuc   B b = a; // expected-error {{no viable}}
912f4a2713aSLionel Sambuc }
913f4a2713aSLionel Sambuc 
914f4a2713aSLionel Sambuc namespace dr85 { // dr85: yes
915f4a2713aSLionel Sambuc   struct A {
916f4a2713aSLionel Sambuc     struct B;
917f4a2713aSLionel Sambuc     struct B {}; // expected-note{{previous declaration is here}}
918f4a2713aSLionel Sambuc     struct B; // expected-error{{class member cannot be redeclared}}
919f4a2713aSLionel Sambuc 
920f4a2713aSLionel Sambuc     union U;
921f4a2713aSLionel Sambuc     union U {}; // expected-note{{previous declaration is here}}
922f4a2713aSLionel Sambuc     union U; // expected-error{{class member cannot be redeclared}}
923f4a2713aSLionel Sambuc 
924f4a2713aSLionel Sambuc #if __cplusplus >= 201103L
925f4a2713aSLionel Sambuc     enum E1 : int;
926f4a2713aSLionel Sambuc     enum E1 : int { e1 }; // expected-note{{previous declaration is here}}
927f4a2713aSLionel Sambuc     enum E1 : int; // expected-error{{class member cannot be redeclared}}
928f4a2713aSLionel Sambuc 
929f4a2713aSLionel Sambuc     enum class E2;
930f4a2713aSLionel Sambuc     enum class E2 { e2 }; // expected-note{{previous declaration is here}}
931f4a2713aSLionel Sambuc     enum class E2; // expected-error{{class member cannot be redeclared}}
932f4a2713aSLionel Sambuc #endif
933f4a2713aSLionel Sambuc   };
934f4a2713aSLionel Sambuc 
935f4a2713aSLionel Sambuc   template <typename T>
936f4a2713aSLionel Sambuc   struct C {
937f4a2713aSLionel Sambuc     struct B {}; // expected-note{{previous declaration is here}}
938f4a2713aSLionel Sambuc     struct B; // expected-error{{class member cannot be redeclared}}
939f4a2713aSLionel Sambuc   };
940f4a2713aSLionel Sambuc }
941f4a2713aSLionel Sambuc 
942f4a2713aSLionel Sambuc // dr86: dup 446
943f4a2713aSLionel Sambuc 
944f4a2713aSLionel Sambuc namespace dr87 { // dr87: no
945f4a2713aSLionel Sambuc   template<typename T> struct X {};
946f4a2713aSLionel Sambuc   // FIXME: This is invalid.
947f4a2713aSLionel Sambuc   X<void() throw()> x;
948f4a2713aSLionel Sambuc   // ... but this is valid.
949f4a2713aSLionel Sambuc   X<void(void() throw())> y;
950f4a2713aSLionel Sambuc }
951f4a2713aSLionel Sambuc 
952f4a2713aSLionel Sambuc namespace dr88 { // dr88: yes
953f4a2713aSLionel Sambuc   template<typename T> struct S {
954*0a6a1f1dSLionel Sambuc     static const int a = 1; // expected-note {{previous}}
955f4a2713aSLionel Sambuc     static const int b;
956f4a2713aSLionel Sambuc   };
957*0a6a1f1dSLionel Sambuc   template<> const int S<int>::a = 4; // expected-error {{already has an initializer}}
958f4a2713aSLionel Sambuc   template<> const int S<int>::b = 4;
959f4a2713aSLionel Sambuc }
960f4a2713aSLionel Sambuc 
961f4a2713aSLionel Sambuc // dr89: na
962f4a2713aSLionel Sambuc 
963f4a2713aSLionel Sambuc namespace dr90 { // dr90: yes
964f4a2713aSLionel Sambuc   struct A {
965f4a2713aSLionel Sambuc     template<typename T> friend void dr90_f(T);
966f4a2713aSLionel Sambuc   };
967f4a2713aSLionel Sambuc   struct B : A {
968f4a2713aSLionel Sambuc     template<typename T> friend void dr90_g(T);
969f4a2713aSLionel Sambuc     struct C {};
970f4a2713aSLionel Sambuc     union D {};
971f4a2713aSLionel Sambuc   };
972f4a2713aSLionel Sambuc   struct E : B {};
973f4a2713aSLionel Sambuc   struct F : B::C {};
974f4a2713aSLionel Sambuc 
test()975f4a2713aSLionel Sambuc   void test() {
976f4a2713aSLionel Sambuc     dr90_f(A());
977f4a2713aSLionel Sambuc     dr90_f(B());
978f4a2713aSLionel Sambuc     dr90_f(B::C()); // expected-error {{undeclared identifier}}
979f4a2713aSLionel Sambuc     dr90_f(B::D()); // expected-error {{undeclared identifier}}
980f4a2713aSLionel Sambuc     dr90_f(E());
981f4a2713aSLionel Sambuc     dr90_f(F()); // expected-error {{undeclared identifier}}
982f4a2713aSLionel Sambuc 
983f4a2713aSLionel Sambuc     dr90_g(A()); // expected-error {{undeclared identifier}}
984f4a2713aSLionel Sambuc     dr90_g(B());
985f4a2713aSLionel Sambuc     dr90_g(B::C());
986f4a2713aSLionel Sambuc     dr90_g(B::D());
987f4a2713aSLionel Sambuc     dr90_g(E());
988f4a2713aSLionel Sambuc     dr90_g(F()); // expected-error {{undeclared identifier}}
989f4a2713aSLionel Sambuc   }
990f4a2713aSLionel Sambuc }
991f4a2713aSLionel Sambuc 
992f4a2713aSLionel Sambuc namespace dr91 { // dr91: yes
993f4a2713aSLionel Sambuc   union U { friend int f(U); };
994f4a2713aSLionel Sambuc   int k = f(U());
995f4a2713aSLionel Sambuc }
996f4a2713aSLionel Sambuc 
997*0a6a1f1dSLionel Sambuc namespace dr92 { // dr92: yes
998*0a6a1f1dSLionel Sambuc   void f() throw(int, float);
999*0a6a1f1dSLionel Sambuc   void (*p)() throw(int) = &f; // expected-error {{target exception specification is not superset of source}}
1000*0a6a1f1dSLionel Sambuc   void (*q)() throw(int);
1001*0a6a1f1dSLionel Sambuc   void (**pp)() throw() = &q; // expected-error {{exception specifications are not allowed}}
1002*0a6a1f1dSLionel Sambuc 
1003*0a6a1f1dSLionel Sambuc   void g(void() throw());
h()1004*0a6a1f1dSLionel Sambuc   void h() {
1005*0a6a1f1dSLionel Sambuc     g(f); // expected-error {{is not superset}}
1006*0a6a1f1dSLionel Sambuc     g(q); // expected-error {{is not superset}}
1007*0a6a1f1dSLionel Sambuc   }
1008*0a6a1f1dSLionel Sambuc 
1009*0a6a1f1dSLionel Sambuc   // Prior to C++17, this is OK because the exception specification is not
1010*0a6a1f1dSLionel Sambuc   // considered in this context. In C++17, we *do* perform an implicit
1011*0a6a1f1dSLionel Sambuc   // conversion (which performs initialization), but we convert to the type of
1012*0a6a1f1dSLionel Sambuc   // the template parameter, which does not include the exception specification.
1013*0a6a1f1dSLionel Sambuc   template<void() throw()> struct X {};
1014*0a6a1f1dSLionel Sambuc   X<&f> xp; // ok
1015*0a6a1f1dSLionel Sambuc }
1016*0a6a1f1dSLionel Sambuc 
1017f4a2713aSLionel Sambuc // dr93: na
1018f4a2713aSLionel Sambuc 
1019f4a2713aSLionel Sambuc namespace dr94 { // dr94: yes
1020f4a2713aSLionel Sambuc   struct A { static const int n = 5; };
1021f4a2713aSLionel Sambuc   int arr[A::n];
1022f4a2713aSLionel Sambuc }
1023f4a2713aSLionel Sambuc 
1024f4a2713aSLionel Sambuc namespace dr95 { // dr95: yes
1025f4a2713aSLionel Sambuc   struct A;
1026f4a2713aSLionel Sambuc   struct B;
1027f4a2713aSLionel Sambuc   namespace N {
1028f4a2713aSLionel Sambuc     class C {
1029f4a2713aSLionel Sambuc       friend struct A;
1030f4a2713aSLionel Sambuc       friend struct B;
1031f4a2713aSLionel Sambuc       static void f(); // expected-note {{here}}
1032f4a2713aSLionel Sambuc     };
1033f4a2713aSLionel Sambuc     struct A *p; // dr95::A, not dr95::N::A.
1034f4a2713aSLionel Sambuc   }
1035f4a2713aSLionel Sambuc   A *q = N::p; // ok, same type
fdr95::B1036f4a2713aSLionel Sambuc   struct B { void f() { N::C::f(); } }; // expected-error {{private}}
1037f4a2713aSLionel Sambuc }
1038f4a2713aSLionel Sambuc 
1039f4a2713aSLionel Sambuc namespace dr96 { // dr96: no
1040f4a2713aSLionel Sambuc   struct A {
1041f4a2713aSLionel Sambuc     void f(int);
1042f4a2713aSLionel Sambuc     template<typename T> int f(T);
1043f4a2713aSLionel Sambuc     template<typename T> struct S {};
1044f4a2713aSLionel Sambuc   } a;
1045f4a2713aSLionel Sambuc   template<template<typename> class X> struct B {};
1046f4a2713aSLionel Sambuc 
1047f4a2713aSLionel Sambuc   template<typename T>
test()1048f4a2713aSLionel Sambuc   void test() {
1049f4a2713aSLionel Sambuc     int k1 = a.template f<int>(0);
1050f4a2713aSLionel Sambuc     // FIXME: This is ill-formed, because 'f' is not a template-id and does not
1051f4a2713aSLionel Sambuc     // name a class template.
1052f4a2713aSLionel Sambuc     // FIXME: What about alias templates?
1053f4a2713aSLionel Sambuc     int k2 = a.template f(1);
1054f4a2713aSLionel Sambuc     A::template S<int> s;
1055f4a2713aSLionel Sambuc     B<A::template S> b;
1056f4a2713aSLionel Sambuc   }
1057f4a2713aSLionel Sambuc }
1058f4a2713aSLionel Sambuc 
1059f4a2713aSLionel Sambuc namespace dr97 { // dr97: yes
1060f4a2713aSLionel Sambuc   struct A {
1061f4a2713aSLionel Sambuc     static const int a = false;
1062f4a2713aSLionel Sambuc     static const int b = !a;
1063f4a2713aSLionel Sambuc   };
1064f4a2713aSLionel Sambuc }
1065f4a2713aSLionel Sambuc 
1066f4a2713aSLionel Sambuc namespace dr98 { // dr98: yes
test(int n)1067f4a2713aSLionel Sambuc   void test(int n) {
1068f4a2713aSLionel Sambuc     switch (n) {
1069f4a2713aSLionel Sambuc       try { // expected-note 2{{bypasses}}
1070*0a6a1f1dSLionel Sambuc         case 0: // expected-error {{cannot jump}}
1071f4a2713aSLionel Sambuc         x:
1072f4a2713aSLionel Sambuc           throw n;
1073f4a2713aSLionel Sambuc       } catch (...) { // expected-note 2{{bypasses}}
1074*0a6a1f1dSLionel Sambuc         case 1: // expected-error {{cannot jump}}
1075f4a2713aSLionel Sambuc         y:
1076f4a2713aSLionel Sambuc           throw n;
1077f4a2713aSLionel Sambuc       }
1078f4a2713aSLionel Sambuc       case 2:
1079*0a6a1f1dSLionel Sambuc         goto x; // expected-error {{cannot jump}}
1080f4a2713aSLionel Sambuc       case 3:
1081*0a6a1f1dSLionel Sambuc         goto y; // expected-error {{cannot jump}}
1082f4a2713aSLionel Sambuc     }
1083f4a2713aSLionel Sambuc   }
1084f4a2713aSLionel Sambuc }
1085f4a2713aSLionel Sambuc 
1086f4a2713aSLionel Sambuc namespace dr99 { // dr99: sup 214
1087f4a2713aSLionel Sambuc   template<typename T> void f(T&);
1088f4a2713aSLionel Sambuc   template<typename T> int &f(const T&);
1089f4a2713aSLionel Sambuc   const int n = 0;
1090f4a2713aSLionel Sambuc   int &r = f(n);
1091f4a2713aSLionel Sambuc }
1092