xref: /minix3/external/bsd/llvm/dist/clang/test/CXX/drs/dr1xx.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
2f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
3*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
4*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
5f4a2713aSLionel Sambuc 
6f4a2713aSLionel Sambuc namespace dr100 { // dr100: yes
7*0a6a1f1dSLionel Sambuc   template<const char *> struct A {}; // expected-note 0-1{{declared here}}
8*0a6a1f1dSLionel Sambuc   template<const char (&)[4]> struct B {}; // expected-note 0-1{{declared here}}
9f4a2713aSLionel Sambuc   A<"foo"> a; // expected-error {{does not refer to any declaration}}
10f4a2713aSLionel Sambuc   B<"bar"> b; // expected-error {{does not refer to any declaration}}
11f4a2713aSLionel Sambuc }
12f4a2713aSLionel Sambuc 
13*0a6a1f1dSLionel Sambuc namespace dr101 { // dr101: 3.5
14f4a2713aSLionel Sambuc   extern "C" void dr101_f();
15f4a2713aSLionel Sambuc   typedef unsigned size_t;
16f4a2713aSLionel Sambuc   namespace X {
17f4a2713aSLionel Sambuc     extern "C" void dr101_f();
18f4a2713aSLionel Sambuc     typedef unsigned size_t;
19f4a2713aSLionel Sambuc   }
20f4a2713aSLionel Sambuc   using X::dr101_f;
21f4a2713aSLionel Sambuc   using X::size_t;
22*0a6a1f1dSLionel Sambuc   extern "C" void dr101_f();
23*0a6a1f1dSLionel Sambuc   typedef unsigned size_t;
24f4a2713aSLionel Sambuc }
25f4a2713aSLionel Sambuc 
26f4a2713aSLionel Sambuc namespace dr102 { // dr102: yes
27f4a2713aSLionel Sambuc   namespace A {
f(T a,T b)28f4a2713aSLionel Sambuc     template<typename T> T f(T a, T b) { return a + b; } // expected-error {{neither visible in the template definition nor found by argument-dependent lookup}}
29f4a2713aSLionel Sambuc   }
30f4a2713aSLionel Sambuc   namespace B {
31f4a2713aSLionel Sambuc     struct S {};
32f4a2713aSLionel Sambuc   }
33f4a2713aSLionel Sambuc   B::S operator+(B::S, B::S); // expected-note {{should be declared prior to the call site or in namespace 'dr102::B'}}
34f4a2713aSLionel Sambuc   template B::S A::f(B::S, B::S); // expected-note {{in instantiation of}}
35f4a2713aSLionel Sambuc }
36f4a2713aSLionel Sambuc 
37f4a2713aSLionel Sambuc // dr103: na
38f4a2713aSLionel Sambuc // dr104 FIXME: add codegen test
39f4a2713aSLionel Sambuc // dr105: na
40f4a2713aSLionel Sambuc 
41f4a2713aSLionel Sambuc namespace dr106 { // dr106: sup 540
42f4a2713aSLionel Sambuc   typedef int &r1;
43f4a2713aSLionel Sambuc   typedef r1 &r1;
44*0a6a1f1dSLionel Sambuc   typedef const r1 r1; // expected-warning {{has no effect}}
45*0a6a1f1dSLionel Sambuc   typedef const r1 &r1; // expected-warning {{has no effect}}
46f4a2713aSLionel Sambuc 
47f4a2713aSLionel Sambuc   typedef const int &r2;
48f4a2713aSLionel Sambuc   typedef r2 &r2;
49*0a6a1f1dSLionel Sambuc   typedef const r2 r2; // expected-warning {{has no effect}}
50*0a6a1f1dSLionel Sambuc   typedef const r2 &r2; // expected-warning {{has no effect}}
51f4a2713aSLionel Sambuc }
52f4a2713aSLionel Sambuc 
53f4a2713aSLionel Sambuc namespace dr107 { // dr107: yes
54f4a2713aSLionel Sambuc   struct S {};
operator +(S,S)55f4a2713aSLionel Sambuc   extern "C" S operator+(S, S) { return S(); }
56f4a2713aSLionel Sambuc }
57f4a2713aSLionel Sambuc 
58f4a2713aSLionel Sambuc namespace dr108 { // dr108: yes
59f4a2713aSLionel Sambuc   template<typename T> struct A {
60f4a2713aSLionel Sambuc     struct B { typedef int X; };
61f4a2713aSLionel Sambuc     B::X x; // expected-error {{missing 'typename'}}
62f4a2713aSLionel Sambuc     struct C : B { X x; }; // expected-error {{unknown type name}}
63f4a2713aSLionel Sambuc   };
64f4a2713aSLionel Sambuc   template<> struct A<int>::B { int X; };
65f4a2713aSLionel Sambuc }
66f4a2713aSLionel Sambuc 
67f4a2713aSLionel Sambuc namespace dr109 { // dr109: yes
68f4a2713aSLionel Sambuc   struct A { template<typename T> void f(T); };
69f4a2713aSLionel Sambuc   template<typename T> struct B : T {
70f4a2713aSLionel Sambuc     using T::template f; // expected-error {{using declaration cannot refer to a template}}
gdr109::B71f4a2713aSLionel Sambuc     void g() { this->f<int>(123); } // expected-error {{use 'template'}}
72f4a2713aSLionel Sambuc   };
73f4a2713aSLionel Sambuc }
74f4a2713aSLionel Sambuc 
75f4a2713aSLionel Sambuc namespace dr111 { // dr111: dup 535
76f4a2713aSLionel Sambuc   struct A { A(); A(volatile A&, int = 0); A(A&, const char * = "foo"); };
77f4a2713aSLionel Sambuc   struct B : A { B(); }; // expected-note +{{would lose const qualifier}} expected-note {{requires 0 arguments}}
78f4a2713aSLionel Sambuc   const B b1;
79f4a2713aSLionel Sambuc   B b2(b1); // expected-error {{no matching constructor}}
80f4a2713aSLionel Sambuc }
81f4a2713aSLionel Sambuc 
82f4a2713aSLionel Sambuc namespace dr112 { // dr112: yes
83f4a2713aSLionel Sambuc   struct T { int n; };
84f4a2713aSLionel Sambuc   typedef T Arr[1];
85f4a2713aSLionel Sambuc 
86f4a2713aSLionel Sambuc   const T a1[1] = {};
87f4a2713aSLionel Sambuc   volatile T a2[1] = {};
88f4a2713aSLionel Sambuc   const Arr a3 = {};
89f4a2713aSLionel Sambuc   volatile Arr a4 = {};
90f4a2713aSLionel Sambuc   template<const volatile T*> struct X {};
91f4a2713aSLionel Sambuc   X<a1> x1;
92f4a2713aSLionel Sambuc   X<a2> x2;
93f4a2713aSLionel Sambuc   X<a3> x3;
94f4a2713aSLionel Sambuc   X<a4> x4;
95f4a2713aSLionel Sambuc #if __cplusplus < 201103L
96f4a2713aSLionel Sambuc   // expected-error@-5 {{internal linkage}} expected-note@-10 {{here}}
97f4a2713aSLionel Sambuc   // expected-error@-4 {{internal linkage}} expected-note@-9 {{here}}
98f4a2713aSLionel Sambuc #else
99f4a2713aSLionel Sambuc   // FIXME: Test this somehow.
100f4a2713aSLionel Sambuc #endif
101f4a2713aSLionel Sambuc }
102f4a2713aSLionel Sambuc 
103f4a2713aSLionel Sambuc namespace dr113 { // dr113: yes
104f4a2713aSLionel Sambuc   extern void (*p)();
f()105f4a2713aSLionel Sambuc   void f() {
106f4a2713aSLionel Sambuc     no_such_function(); // expected-error {{undeclared}}
107f4a2713aSLionel Sambuc     p();
108f4a2713aSLionel Sambuc   }
109f4a2713aSLionel Sambuc   void g();
110f4a2713aSLionel Sambuc   void (*p)() = &g;
111f4a2713aSLionel Sambuc }
112f4a2713aSLionel Sambuc 
113f4a2713aSLionel Sambuc namespace dr114 { // dr114: yes
114f4a2713aSLionel Sambuc   struct A {
115f4a2713aSLionel Sambuc     virtual void f(int) = 0; // expected-note {{unimplemented}}
116f4a2713aSLionel Sambuc   };
117f4a2713aSLionel Sambuc   struct B : A {
118f4a2713aSLionel Sambuc     template<typename T> void f(T);
gdr114::B119f4a2713aSLionel Sambuc     void g() { f(0); }
120f4a2713aSLionel Sambuc   } b; // expected-error {{abstract}}
121f4a2713aSLionel Sambuc }
122f4a2713aSLionel Sambuc 
123f4a2713aSLionel Sambuc namespace dr115 { // dr115: yes
124f4a2713aSLionel Sambuc   template<typename T> int f(T); // expected-note +{{}}
125f4a2713aSLionel Sambuc   template<typename T> int g(T); // expected-note +{{}}
126f4a2713aSLionel Sambuc   template<typename T> int g(T, int); // expected-note +{{}}
127f4a2713aSLionel Sambuc 
128f4a2713aSLionel Sambuc   int k1 = f(&f); // expected-error {{no match}}
129f4a2713aSLionel Sambuc   int k2 = f(&f<int>);
130f4a2713aSLionel Sambuc   int k3 = f(&g<int>); // expected-error {{no match}}
131f4a2713aSLionel Sambuc 
h()132f4a2713aSLionel Sambuc   void h() {
133f4a2713aSLionel Sambuc     (void)&f; // expected-error {{address of overloaded function 'f' cannot be cast to type 'void'}}
134f4a2713aSLionel Sambuc     (void)&f<int>;
135f4a2713aSLionel Sambuc     (void)&g<int>; // expected-error {{address of overloaded function 'g' cannot be cast to type 'void'}}
136f4a2713aSLionel Sambuc 
137f4a2713aSLionel Sambuc     &f; // expected-error {{reference to overloaded function could not be resolved}}
138f4a2713aSLionel Sambuc     &f<int>; // expected-warning {{unused}}
139f4a2713aSLionel Sambuc     &g<int>; // expected-error {{reference to overloaded function could not be resolved}}
140f4a2713aSLionel Sambuc   }
141f4a2713aSLionel Sambuc 
142f4a2713aSLionel Sambuc   struct S {
143f4a2713aSLionel Sambuc     template<typename T> static int f(T);
144f4a2713aSLionel Sambuc     template<typename T> static int g(T);
145f4a2713aSLionel Sambuc     template<typename T> static int g(T, int);
146f4a2713aSLionel Sambuc   } s;
147f4a2713aSLionel Sambuc 
148f4a2713aSLionel Sambuc   int k4 = f(&s.f); // expected-error {{non-constant pointer to member}}
149f4a2713aSLionel Sambuc   int k5 = f(&s.f<int>);
150f4a2713aSLionel Sambuc   int k6 = f(&s.g<int>); // expected-error {{non-constant pointer to member}}
151f4a2713aSLionel Sambuc 
i()152f4a2713aSLionel Sambuc   void i() {
153f4a2713aSLionel Sambuc     (void)&s.f; // expected-error {{non-constant pointer to member}}
154f4a2713aSLionel Sambuc     (void)&s.f<int>;
155f4a2713aSLionel Sambuc     (void)&s.g<int>; // expected-error {{non-constant pointer to member}}
156f4a2713aSLionel Sambuc 
157f4a2713aSLionel Sambuc     &s.f; // expected-error {{non-constant pointer to member}}
158f4a2713aSLionel Sambuc     &s.f<int>; // expected-warning {{unused}}
159f4a2713aSLionel Sambuc     &s.g<int>; // expected-error {{non-constant pointer to member}}
160f4a2713aSLionel Sambuc   }
161f4a2713aSLionel Sambuc 
162f4a2713aSLionel Sambuc   struct T {
163f4a2713aSLionel Sambuc     template<typename T> int f(T);
164f4a2713aSLionel Sambuc     template<typename T> int g(T);
165f4a2713aSLionel Sambuc     template<typename T> int g(T, int);
166f4a2713aSLionel Sambuc   } t;
167f4a2713aSLionel Sambuc 
168f4a2713aSLionel Sambuc   int k7 = f(&s.f); // expected-error {{non-constant pointer to member}}
169f4a2713aSLionel Sambuc   int k8 = f(&s.f<int>);
170f4a2713aSLionel Sambuc   int k9 = f(&s.g<int>); // expected-error {{non-constant pointer to member}}
171f4a2713aSLionel Sambuc 
j()172f4a2713aSLionel Sambuc   void j() {
173f4a2713aSLionel Sambuc     (void)&s.f; // expected-error {{non-constant pointer to member}}
174f4a2713aSLionel Sambuc     (void)&s.f<int>;
175f4a2713aSLionel Sambuc     (void)&s.g<int>; // expected-error {{non-constant pointer to member}}
176f4a2713aSLionel Sambuc 
177f4a2713aSLionel Sambuc     &s.f; // expected-error {{non-constant pointer to member}}
178f4a2713aSLionel Sambuc     &s.f<int>; // expected-warning {{unused}}
179f4a2713aSLionel Sambuc     &s.g<int>; // expected-error {{non-constant pointer to member}}
180f4a2713aSLionel Sambuc   }
181f4a2713aSLionel Sambuc 
182f4a2713aSLionel Sambuc #if __cplusplus >= 201103L
183f4a2713aSLionel Sambuc   // Special case kicks in only if a template argument list is specified.
184f4a2713aSLionel Sambuc   template<typename T=int> void with_default(); // expected-note +{{}}
185f4a2713aSLionel Sambuc   int k10 = f(&with_default); // expected-error {{no matching function}}
186f4a2713aSLionel Sambuc   int k11 = f(&with_default<>);
k()187f4a2713aSLionel Sambuc   void k() {
188f4a2713aSLionel Sambuc     (void)&with_default; // expected-error {{overloaded function}}
189f4a2713aSLionel Sambuc     (void)&with_default<>;
190f4a2713aSLionel Sambuc     &with_default; // expected-error {{overloaded function}}
191f4a2713aSLionel Sambuc     &with_default<>; // expected-warning {{unused}}
192f4a2713aSLionel Sambuc   }
193f4a2713aSLionel Sambuc #endif
194f4a2713aSLionel Sambuc }
195f4a2713aSLionel Sambuc 
196f4a2713aSLionel Sambuc namespace dr116 { // dr116: yes
197f4a2713aSLionel Sambuc   template<int> struct A {};
f(A<N>)198f4a2713aSLionel Sambuc   template<int N> void f(A<N>) {} // expected-note {{previous}}
f(A<M>)199f4a2713aSLionel Sambuc   template<int M> void f(A<M>) {} // expected-error {{redefinition}}
f(A<sizeof (T)>)200f4a2713aSLionel Sambuc   template<typename T> void f(A<sizeof(T)>) {} // expected-note {{previous}}
f(A<sizeof (U)>)201f4a2713aSLionel Sambuc   template<typename U> void f(A<sizeof(U)>) {} // expected-error {{redefinition}}
202f4a2713aSLionel Sambuc }
203f4a2713aSLionel Sambuc 
204f4a2713aSLionel Sambuc // dr117: na
205f4a2713aSLionel Sambuc // dr118 FIXME: add codegen test
206f4a2713aSLionel Sambuc // dr119: na
207f4a2713aSLionel Sambuc // dr120: na
208f4a2713aSLionel Sambuc 
209f4a2713aSLionel Sambuc namespace dr121 { // dr121: yes
210f4a2713aSLionel Sambuc   struct X {
211f4a2713aSLionel Sambuc     template<typename T> struct Y {};
212f4a2713aSLionel Sambuc   };
213f4a2713aSLionel Sambuc   template<typename T> struct Z {
214f4a2713aSLionel Sambuc     X::Y<T> x;
215f4a2713aSLionel Sambuc     T::Y<T> y; // expected-error +{{}}
216f4a2713aSLionel Sambuc   };
217f4a2713aSLionel Sambuc   Z<X> z;
218f4a2713aSLionel Sambuc }
219f4a2713aSLionel Sambuc 
220f4a2713aSLionel Sambuc namespace dr122 { // dr122: yes
221f4a2713aSLionel Sambuc   template<typename T> void f();
g()222f4a2713aSLionel Sambuc   void g() { f<int>(); }
223f4a2713aSLionel Sambuc }
224f4a2713aSLionel Sambuc 
225f4a2713aSLionel Sambuc // dr123: na
226f4a2713aSLionel Sambuc // dr124: dup 201
227f4a2713aSLionel Sambuc 
228f4a2713aSLionel Sambuc // dr125: yes
229f4a2713aSLionel Sambuc struct dr125_A { struct dr125_B {}; }; // expected-note {{here}}
230f4a2713aSLionel Sambuc dr125_A::dr125_B dr125_C();
231f4a2713aSLionel Sambuc namespace dr125_B { dr125_A dr125_C(); }
232f4a2713aSLionel Sambuc namespace dr125 {
233f4a2713aSLionel Sambuc   struct X {
234f4a2713aSLionel Sambuc     friend dr125_A::dr125_B (::dr125_C)(); // ok
235f4a2713aSLionel Sambuc     friend dr125_A (::dr125_B::dr125_C)(); // ok
236f4a2713aSLionel Sambuc     friend dr125_A::dr125_B::dr125_C(); // expected-error {{did you mean the constructor name 'dr125_B'?}}
237f4a2713aSLionel Sambuc     // expected-warning@-1 {{missing exception specification}}
238f4a2713aSLionel Sambuc #if __cplusplus >= 201103L
239f4a2713aSLionel Sambuc     // expected-error@-3 {{follows constexpr declaration}} expected-note@-10 {{here}}
240f4a2713aSLionel Sambuc #endif
241f4a2713aSLionel Sambuc   };
242f4a2713aSLionel Sambuc }
243f4a2713aSLionel Sambuc 
244f4a2713aSLionel Sambuc namespace dr126 { // dr126: no
245f4a2713aSLionel Sambuc   struct C {};
246f4a2713aSLionel Sambuc   struct D : C {};
247f4a2713aSLionel Sambuc   struct E : private C { friend class A; friend class B; };
248f4a2713aSLionel Sambuc   struct F : protected C {};
249f4a2713aSLionel Sambuc   struct G : C {};
250f4a2713aSLionel Sambuc   struct H : D, G {};
251f4a2713aSLionel Sambuc 
252f4a2713aSLionel Sambuc   struct A {
253f4a2713aSLionel Sambuc     virtual void cp() throw(C*);
254f4a2713aSLionel Sambuc     virtual void dp() throw(C*);
255f4a2713aSLionel Sambuc     virtual void ep() throw(C*); // expected-note {{overridden}}
256f4a2713aSLionel Sambuc     virtual void fp() throw(C*); // expected-note {{overridden}}
257f4a2713aSLionel Sambuc     virtual void gp() throw(C*);
258f4a2713aSLionel Sambuc     virtual void hp() throw(C*); // expected-note {{overridden}}
259f4a2713aSLionel Sambuc 
260f4a2713aSLionel Sambuc     virtual void cr() throw(C&);
261f4a2713aSLionel Sambuc     virtual void dr() throw(C&);
262f4a2713aSLionel Sambuc     virtual void er() throw(C&); // expected-note {{overridden}}
263f4a2713aSLionel Sambuc     virtual void fr() throw(C&); // expected-note {{overridden}}
264f4a2713aSLionel Sambuc     virtual void gr() throw(C&);
265f4a2713aSLionel Sambuc     virtual void hr() throw(C&); // expected-note {{overridden}}
266f4a2713aSLionel Sambuc 
267f4a2713aSLionel Sambuc     virtual void pv() throw(void*); // expected-note {{overridden}}
268f4a2713aSLionel Sambuc 
269f4a2713aSLionel Sambuc #if __cplusplus >= 201103L
270f4a2713aSLionel Sambuc     virtual void np() throw(C*); // expected-note {{overridden}}
271f4a2713aSLionel Sambuc     virtual void npm() throw(int C::*); // expected-note {{overridden}}
272f4a2713aSLionel Sambuc     virtual void nr() throw(C&); // expected-note {{overridden}}
273f4a2713aSLionel Sambuc #endif
274f4a2713aSLionel Sambuc 
275f4a2713aSLionel Sambuc     virtual void ref1() throw(C *const&);
276f4a2713aSLionel Sambuc     virtual void ref2() throw(C *);
277f4a2713aSLionel Sambuc 
278f4a2713aSLionel Sambuc     virtual void v() throw(int);
279f4a2713aSLionel Sambuc     virtual void w() throw(const int);
280f4a2713aSLionel Sambuc     virtual void x() throw(int*);
281f4a2713aSLionel Sambuc     virtual void y() throw(const int*);
282f4a2713aSLionel Sambuc     virtual void z() throw(int); // expected-note {{overridden}}
283f4a2713aSLionel Sambuc   };
284f4a2713aSLionel Sambuc   struct B : A {
285f4a2713aSLionel Sambuc     virtual void cp() throw(C*);
286f4a2713aSLionel Sambuc     virtual void dp() throw(D*);
287f4a2713aSLionel Sambuc     virtual void ep() throw(E*); // expected-error {{more lax}}
288f4a2713aSLionel Sambuc     virtual void fp() throw(F*); // expected-error {{more lax}}
289f4a2713aSLionel Sambuc     virtual void gp() throw(G*);
290f4a2713aSLionel Sambuc     virtual void hp() throw(H*); // expected-error {{more lax}}
291f4a2713aSLionel Sambuc 
292f4a2713aSLionel Sambuc     virtual void cr() throw(C&);
293f4a2713aSLionel Sambuc     virtual void dr() throw(D&);
294f4a2713aSLionel Sambuc     virtual void er() throw(E&); // expected-error {{more lax}}
295f4a2713aSLionel Sambuc     virtual void fr() throw(F&); // expected-error {{more lax}}
296f4a2713aSLionel Sambuc     virtual void gr() throw(G&);
297f4a2713aSLionel Sambuc     virtual void hr() throw(H&); // expected-error {{more lax}}
298f4a2713aSLionel Sambuc 
299f4a2713aSLionel Sambuc     virtual void pv() throw(C*); // expected-error {{more lax}} FIXME: This is valid.
300f4a2713aSLionel Sambuc 
301f4a2713aSLionel Sambuc #if __cplusplus >= 201103L
302f4a2713aSLionel Sambuc     using nullptr_t = decltype(nullptr);
303f4a2713aSLionel Sambuc     virtual void np() throw(nullptr_t*); // expected-error {{more lax}} FIXME: This is valid.
304f4a2713aSLionel Sambuc     virtual void npm() throw(nullptr_t*); // expected-error {{more lax}} FIXME: This is valid.
305f4a2713aSLionel Sambuc     virtual void nr() throw(nullptr_t&); // expected-error {{more lax}} This is not.
306f4a2713aSLionel Sambuc #endif
307f4a2713aSLionel Sambuc 
308f4a2713aSLionel Sambuc     virtual void ref1() throw(D *const &);
309f4a2713aSLionel Sambuc     virtual void ref2() throw(D *);
310f4a2713aSLionel Sambuc 
311f4a2713aSLionel Sambuc     virtual void v() throw(const int);
312f4a2713aSLionel Sambuc     virtual void w() throw(int);
313f4a2713aSLionel Sambuc     virtual void x() throw(const int*); // FIXME: 'const int*' is not allowed by A::h.
314f4a2713aSLionel Sambuc     virtual void y() throw(int*); // ok
315f4a2713aSLionel Sambuc     virtual void z() throw(long); // expected-error {{more lax}}
316f4a2713aSLionel Sambuc   };
317f4a2713aSLionel Sambuc }
318f4a2713aSLionel Sambuc 
319f4a2713aSLionel Sambuc namespace dr127 { // dr127: yes
320f4a2713aSLionel Sambuc   __extension__ typedef __decltype(sizeof(0)) size_t;
321f4a2713aSLionel Sambuc   template<typename T> struct A {
322f4a2713aSLionel Sambuc     A() throw(int);
323f4a2713aSLionel Sambuc     void *operator new(size_t, const char * = 0);
operator deletedr127::A324f4a2713aSLionel Sambuc     void operator delete(void *, const char *) { T::error; } // expected-error 2{{no members}}
operator deletedr127::A325f4a2713aSLionel Sambuc     void operator delete(void *) { T::error; }
326f4a2713aSLionel Sambuc   };
327f4a2713aSLionel Sambuc   A<void> *p = new A<void>; // expected-note {{instantiat}}
328f4a2713aSLionel Sambuc   A<int> *q = new ("") A<int>; // expected-note {{instantiat}}
329f4a2713aSLionel Sambuc }
330f4a2713aSLionel Sambuc 
331f4a2713aSLionel Sambuc namespace dr128 { // dr128: yes
332f4a2713aSLionel Sambuc   enum E1 { e1 } x = e1;
333f4a2713aSLionel Sambuc   enum E2 { e2 } y = static_cast<E2>(x), z = static_cast<E2>(e1);
334f4a2713aSLionel Sambuc }
335f4a2713aSLionel Sambuc 
336f4a2713aSLionel Sambuc // dr129: dup 616
337f4a2713aSLionel Sambuc // dr130: na
338f4a2713aSLionel Sambuc 
339f4a2713aSLionel Sambuc namespace dr131 { // dr131: yes
340f4a2713aSLionel Sambuc   const char *a_with_\u0e8c = "\u0e8c";
341f4a2713aSLionel Sambuc   const char *b_with_\u0e8d = "\u0e8d";
342f4a2713aSLionel Sambuc   const char *c_with_\u0e8e = "\u0e8e";
343f4a2713aSLionel Sambuc #if __cplusplus < 201103L
344f4a2713aSLionel Sambuc   // expected-error@-4 {{expected ';'}} expected-error@-2 {{expected ';'}}
345f4a2713aSLionel Sambuc #endif
346f4a2713aSLionel Sambuc }
347f4a2713aSLionel Sambuc 
348f4a2713aSLionel Sambuc namespace dr132 { // dr132: no
f()349f4a2713aSLionel Sambuc   void f() {
350f4a2713aSLionel Sambuc     extern struct {} x; // ok
351f4a2713aSLionel Sambuc     extern struct S {} y; // FIXME: This is invalid.
352f4a2713aSLionel Sambuc   }
353f4a2713aSLionel Sambuc   static enum { E } e;
354f4a2713aSLionel Sambuc }
355f4a2713aSLionel Sambuc 
356f4a2713aSLionel Sambuc // dr133: dup 87
357f4a2713aSLionel Sambuc // dr134: na
358f4a2713aSLionel Sambuc 
359f4a2713aSLionel Sambuc namespace dr135 { // dr135: yes
360f4a2713aSLionel Sambuc   struct A {
fdr135::A361f4a2713aSLionel Sambuc     A f(A a) { return a; }
g(A a)362f4a2713aSLionel Sambuc     friend A g(A a) { return a; }
hdr135::A363f4a2713aSLionel Sambuc     static A h(A a) { return a; }
364f4a2713aSLionel Sambuc   };
365f4a2713aSLionel Sambuc }
366f4a2713aSLionel Sambuc 
367f4a2713aSLionel Sambuc namespace dr136 { // dr136: 3.4
368f4a2713aSLionel Sambuc   void f(int, int, int = 0); // expected-note {{previous declaration is here}}
369f4a2713aSLionel Sambuc   void g(int, int, int); // expected-note {{previous declaration is here}}
370f4a2713aSLionel Sambuc   struct A {
371f4a2713aSLionel Sambuc     friend void f(int, int = 0, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
372f4a2713aSLionel Sambuc     friend void g(int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
373f4a2713aSLionel Sambuc     friend void h(int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be a definition}}
i(int,int,int=0)374f4a2713aSLionel Sambuc     friend void i(int, int, int = 0) {} // expected-note {{previous declaration is here}}
j(int,int,int=0)375f4a2713aSLionel Sambuc     friend void j(int, int, int = 0) {}
376f4a2713aSLionel Sambuc     operator int();
377f4a2713aSLionel Sambuc   };
378f4a2713aSLionel Sambuc   void i(int, int, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
q()379f4a2713aSLionel Sambuc   void q() {
380f4a2713aSLionel Sambuc     j(A(), A()); // ok, has default argument
381f4a2713aSLionel Sambuc   }
382f4a2713aSLionel Sambuc   extern "C" void k(int, int, int, int); // expected-note {{previous declaration is here}}
383f4a2713aSLionel Sambuc   namespace NSA {
384f4a2713aSLionel Sambuc   struct A {
385f4a2713aSLionel Sambuc     friend void dr136::k(int, int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}} \
386f4a2713aSLionel Sambuc                                                   // expected-note {{previous declaration is here}}
387f4a2713aSLionel Sambuc   };
388f4a2713aSLionel Sambuc   }
389f4a2713aSLionel Sambuc   namespace NSB {
390f4a2713aSLionel Sambuc   struct A {
391f4a2713aSLionel Sambuc     friend void dr136::k(int, int, int = 0, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
392f4a2713aSLionel Sambuc   };
393f4a2713aSLionel Sambuc   }
394f4a2713aSLionel Sambuc   struct B {
395f4a2713aSLionel Sambuc     void f(int); // expected-note {{previous declaration is here}}
396f4a2713aSLionel Sambuc   };
397f4a2713aSLionel Sambuc   struct C {
398f4a2713aSLionel Sambuc     friend void B::f(int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
399f4a2713aSLionel Sambuc   };
400f4a2713aSLionel Sambuc }
401f4a2713aSLionel Sambuc 
402f4a2713aSLionel Sambuc namespace dr137 { // dr137: yes
403f4a2713aSLionel Sambuc   extern void *p;
404f4a2713aSLionel Sambuc   extern const void *cp;
405f4a2713aSLionel Sambuc   extern volatile void *vp;
406f4a2713aSLionel Sambuc   extern const volatile void *cvp;
407f4a2713aSLionel Sambuc   int *q = static_cast<int*>(p);
408f4a2713aSLionel Sambuc   int *qc = static_cast<int*>(cp); // expected-error {{casts away qualifiers}}
409f4a2713aSLionel Sambuc   int *qv = static_cast<int*>(vp); // expected-error {{casts away qualifiers}}
410f4a2713aSLionel Sambuc   int *qcv = static_cast<int*>(cvp); // expected-error {{casts away qualifiers}}
411f4a2713aSLionel Sambuc   const int *cq = static_cast<const int*>(p);
412f4a2713aSLionel Sambuc   const int *cqc = static_cast<const int*>(cp);
413f4a2713aSLionel Sambuc   const int *cqv = static_cast<const int*>(vp); // expected-error {{casts away qualifiers}}
414f4a2713aSLionel Sambuc   const int *cqcv = static_cast<const int*>(cvp); // expected-error {{casts away qualifiers}}
415f4a2713aSLionel Sambuc   const volatile int *cvq = static_cast<const volatile int*>(p);
416f4a2713aSLionel Sambuc   const volatile int *cvqc = static_cast<const volatile int*>(cp);
417f4a2713aSLionel Sambuc   const volatile int *cvqv = static_cast<const volatile int*>(vp);
418f4a2713aSLionel Sambuc   const volatile int *cvqcv = static_cast<const volatile int*>(cvp);
419f4a2713aSLionel Sambuc }
420f4a2713aSLionel Sambuc 
421f4a2713aSLionel Sambuc namespace dr139 { // dr139: yes
422f4a2713aSLionel Sambuc   namespace example1 {
423f4a2713aSLionel Sambuc     typedef int f; // expected-note {{previous}}
424f4a2713aSLionel Sambuc     struct A {
425f4a2713aSLionel Sambuc       friend void f(A &); // expected-error {{different kind of symbol}}
426f4a2713aSLionel Sambuc     };
427f4a2713aSLionel Sambuc   }
428f4a2713aSLionel Sambuc 
429f4a2713aSLionel Sambuc   namespace example2 {
430f4a2713aSLionel Sambuc     typedef int f;
431f4a2713aSLionel Sambuc     namespace N {
432f4a2713aSLionel Sambuc       struct A {
433f4a2713aSLionel Sambuc         friend void f(A &);
434f4a2713aSLionel Sambuc         operator int();
gdr139::example2::N::A435f4a2713aSLionel Sambuc         void g(A a) { int i = f(a); } // ok, f is typedef not friend function
436f4a2713aSLionel Sambuc       };
437f4a2713aSLionel Sambuc     }
438f4a2713aSLionel Sambuc   }
439f4a2713aSLionel Sambuc }
440f4a2713aSLionel Sambuc 
441f4a2713aSLionel Sambuc namespace dr140 { // dr140: yes
f(int * const)442f4a2713aSLionel Sambuc   void f(int *const) {} // expected-note {{previous}}
f(int[3])443f4a2713aSLionel Sambuc   void f(int[3]) {} // expected-error {{redefinition}}
444f4a2713aSLionel Sambuc   void g(const int);
g(int n)445f4a2713aSLionel Sambuc   void g(int n) { n = 2; }
446f4a2713aSLionel Sambuc }
447f4a2713aSLionel Sambuc 
448f4a2713aSLionel Sambuc namespace dr141 { // dr141: yes
449f4a2713aSLionel Sambuc   template<typename T> void f();
450f4a2713aSLionel Sambuc   template<typename T> struct S { int n; };
451f4a2713aSLionel Sambuc   struct A : S<int> {
452f4a2713aSLionel Sambuc     template<typename T> void f();
453f4a2713aSLionel Sambuc     template<typename T> struct S {};
454f4a2713aSLionel Sambuc   } a;
455f4a2713aSLionel Sambuc   struct B : S<int> {} b;
g()456f4a2713aSLionel Sambuc   void g() {
457f4a2713aSLionel Sambuc     a.f<int>();
458f4a2713aSLionel Sambuc     (void)a.S<int>::n; // expected-error {{no member named 'n'}}
459f4a2713aSLionel Sambuc #if __cplusplus < 201103L
460f4a2713aSLionel Sambuc     // expected-error@-2 {{ambiguous}}
461f4a2713aSLionel Sambuc     // expected-note@-11 {{lookup from the current scope}}
462f4a2713aSLionel Sambuc     // expected-note@-9 {{lookup in the object type}}
463f4a2713aSLionel Sambuc #endif
464f4a2713aSLionel Sambuc     b.f<int>(); // expected-error {{no member}} expected-error +{{}}
465f4a2713aSLionel Sambuc     (void)b.S<int>::n;
466f4a2713aSLionel Sambuc   }
467f4a2713aSLionel Sambuc   template<typename T> struct C {
468f4a2713aSLionel Sambuc     T t;
gdr141::C469f4a2713aSLionel Sambuc     void g() {
470f4a2713aSLionel Sambuc       t.f<int>(); // expected-error {{use 'template'}}
471f4a2713aSLionel Sambuc     }
hdr141::C472f4a2713aSLionel Sambuc     void h() {
473f4a2713aSLionel Sambuc       (void)t.S<int>::n; // ok
474f4a2713aSLionel Sambuc     }
idr141::C475f4a2713aSLionel Sambuc     void i() {
476f4a2713aSLionel Sambuc       (void)t.S<int>(); // ok!
477f4a2713aSLionel Sambuc     }
478f4a2713aSLionel Sambuc   };
h()479f4a2713aSLionel Sambuc   void h() { C<B>().h(); } // ok
480f4a2713aSLionel Sambuc   struct X {
481f4a2713aSLionel Sambuc     template<typename T> void S();
482f4a2713aSLionel Sambuc   };
i()483f4a2713aSLionel Sambuc   void i() { C<X>().i(); } // ok!!
484f4a2713aSLionel Sambuc }
485f4a2713aSLionel Sambuc 
486f4a2713aSLionel Sambuc namespace dr142 { // dr142: yes
487f4a2713aSLionel Sambuc   class B { // expected-note +{{here}}
488f4a2713aSLionel Sambuc   public:
489f4a2713aSLionel Sambuc     int mi; // expected-note +{{here}}
490f4a2713aSLionel Sambuc     static int si; // expected-note +{{here}}
491f4a2713aSLionel Sambuc   };
492f4a2713aSLionel Sambuc   class D : private B { // expected-note +{{here}}
493f4a2713aSLionel Sambuc   };
494f4a2713aSLionel Sambuc   class DD : public D {
495f4a2713aSLionel Sambuc     void f();
496f4a2713aSLionel Sambuc   };
f()497f4a2713aSLionel Sambuc   void DD::f() {
498f4a2713aSLionel Sambuc     mi = 3; // expected-error {{private base class}} expected-error {{private member}}
499f4a2713aSLionel Sambuc     si = 3; // expected-error {{private member}}
500f4a2713aSLionel Sambuc     B b_old; // expected-error {{private member}}
501f4a2713aSLionel Sambuc     dr142::B b;
502f4a2713aSLionel Sambuc     b.mi = 3;
503f4a2713aSLionel Sambuc     b.si = 3;
504f4a2713aSLionel Sambuc     B::si = 3; // expected-error {{private member}}
505f4a2713aSLionel Sambuc     dr142::B::si = 3;
506f4a2713aSLionel Sambuc     B *bp1_old = this; // expected-error {{private member}} expected-error {{private base class}}
507f4a2713aSLionel Sambuc     dr142::B *bp1 = this; // expected-error {{private base class}}
508f4a2713aSLionel Sambuc     B *bp2_old = (B*)this; // expected-error 2{{private member}}
509f4a2713aSLionel Sambuc     dr142::B *bp2 = (dr142::B*)this;
510f4a2713aSLionel Sambuc     bp2->mi = 3;
511f4a2713aSLionel Sambuc   }
512f4a2713aSLionel Sambuc }
513f4a2713aSLionel Sambuc 
514f4a2713aSLionel Sambuc namespace dr143 { // dr143: yes
515f4a2713aSLionel Sambuc   namespace A { struct X; }
516f4a2713aSLionel Sambuc   namespace B { void f(A::X); }
517f4a2713aSLionel Sambuc   namespace A {
518f4a2713aSLionel Sambuc     struct X { friend void B::f(X); };
519f4a2713aSLionel Sambuc   }
g(A::X x)520f4a2713aSLionel Sambuc   void g(A::X x) {
521f4a2713aSLionel Sambuc     f(x); // expected-error {{undeclared identifier 'f'}}
522f4a2713aSLionel Sambuc   }
523f4a2713aSLionel Sambuc }
524f4a2713aSLionel Sambuc 
525f4a2713aSLionel Sambuc namespace dr145 { // dr145: yes
f(bool b)526f4a2713aSLionel Sambuc   void f(bool b) {
527f4a2713aSLionel Sambuc     ++b; // expected-warning {{deprecated}}
528f4a2713aSLionel Sambuc     b++; // expected-warning {{deprecated}}
529f4a2713aSLionel Sambuc   }
530f4a2713aSLionel Sambuc }
531f4a2713aSLionel Sambuc 
532f4a2713aSLionel Sambuc namespace dr147 { // dr147: no
533f4a2713aSLionel Sambuc   namespace example1 {
534f4a2713aSLionel Sambuc     template<typename> struct A {
535f4a2713aSLionel Sambuc       template<typename T> A(T);
536f4a2713aSLionel Sambuc     };
537f4a2713aSLionel Sambuc     // FIXME: This appears to be valid, and EDG and G++ accept.
A(int)538f4a2713aSLionel Sambuc     template<> template<> A<int>::A<int>(int) {} // expected-error {{out-of-line constructor for 'A' cannot have template arguments}}
539f4a2713aSLionel Sambuc   }
540f4a2713aSLionel Sambuc   namespace example2 {
541f4a2713aSLionel Sambuc     struct A { A(); };
542f4a2713aSLionel Sambuc     struct B : A { B(); };
543f4a2713aSLionel Sambuc     A::A a1; // expected-error {{is a constructor}}
544f4a2713aSLionel Sambuc     B::A a2;
545f4a2713aSLionel Sambuc   }
546f4a2713aSLionel Sambuc   namespace example3 {
547f4a2713aSLionel Sambuc     template<typename> struct A {
548f4a2713aSLionel Sambuc       template<typename T> A(T);
549f4a2713aSLionel Sambuc       static A a;
550f4a2713aSLionel Sambuc     };
551f4a2713aSLionel Sambuc     template<> A<int>::A<int>(A<int>::a); // expected-error {{is a constructor}}
552f4a2713aSLionel Sambuc   }
553f4a2713aSLionel Sambuc }
554f4a2713aSLionel Sambuc 
555f4a2713aSLionel Sambuc namespace dr148 { // dr148: yes
556f4a2713aSLionel Sambuc   struct A { int A::*p; };
557f4a2713aSLionel Sambuc   int check1[__is_pod(int(A::*)) ? 1 : -1];
558f4a2713aSLionel Sambuc   int check2[__is_pod(A) ? 1 : -1];
559f4a2713aSLionel Sambuc }
560f4a2713aSLionel Sambuc 
561f4a2713aSLionel Sambuc // dr149: na
562f4a2713aSLionel Sambuc 
563f4a2713aSLionel Sambuc namespace dr151 { // dr151: yes
564f4a2713aSLionel Sambuc   struct X {};
565f4a2713aSLionel Sambuc   typedef int X::*p;
566f4a2713aSLionel Sambuc #if __cplusplus < 201103L
567f4a2713aSLionel Sambuc #define fold(x) (__builtin_constant_p(0) ? (x) : (x))
568f4a2713aSLionel Sambuc #else
569f4a2713aSLionel Sambuc #define fold
570f4a2713aSLionel Sambuc #endif
571f4a2713aSLionel Sambuc   int check[fold(p() == 0) ? 1 : -1];
572f4a2713aSLionel Sambuc #undef fold
573f4a2713aSLionel Sambuc }
574f4a2713aSLionel Sambuc 
575f4a2713aSLionel Sambuc namespace dr152 { // dr152: yes
576f4a2713aSLionel Sambuc   struct A {
577f4a2713aSLionel Sambuc     A(); // expected-note {{not viable}}
578f4a2713aSLionel Sambuc     explicit A(const A&);
579f4a2713aSLionel Sambuc   };
580f4a2713aSLionel Sambuc   A a1 = A(); // expected-error {{no matching constructor}}
581f4a2713aSLionel Sambuc   A a2((A()));
582f4a2713aSLionel Sambuc }
583f4a2713aSLionel Sambuc 
584f4a2713aSLionel Sambuc // dr153: na
585f4a2713aSLionel Sambuc 
586f4a2713aSLionel Sambuc namespace dr154 { // dr154: yes
587f4a2713aSLionel Sambuc   union { int a; }; // expected-error {{must be declared 'static'}}
588f4a2713aSLionel Sambuc   namespace {
589f4a2713aSLionel Sambuc     union { int b; };
590f4a2713aSLionel Sambuc   }
591f4a2713aSLionel Sambuc   static union { int c; };
592f4a2713aSLionel Sambuc }
593f4a2713aSLionel Sambuc 
594f4a2713aSLionel Sambuc namespace dr155 { // dr155: dup 632
595f4a2713aSLionel Sambuc   struct S { int n; } s = { { 1 } }; // expected-warning {{braces around scalar initializer}}
596f4a2713aSLionel Sambuc }
597f4a2713aSLionel Sambuc 
598*0a6a1f1dSLionel Sambuc // dr158 FIXME write codegen test
599*0a6a1f1dSLionel Sambuc 
600*0a6a1f1dSLionel Sambuc namespace dr159 { // dr159: 3.5
601f4a2713aSLionel Sambuc   namespace X { void f(); }
602f4a2713aSLionel Sambuc   void f();
f()603*0a6a1f1dSLionel Sambuc   void dr159::f() {} // expected-warning {{extra qualification}}
f()604f4a2713aSLionel Sambuc   void dr159::X::f() {}
605f4a2713aSLionel Sambuc }
606f4a2713aSLionel Sambuc 
607f4a2713aSLionel Sambuc // dr160: na
608f4a2713aSLionel Sambuc 
609f4a2713aSLionel Sambuc namespace dr161 { // dr161: yes
610f4a2713aSLionel Sambuc   class A {
611f4a2713aSLionel Sambuc   protected:
612f4a2713aSLionel Sambuc     struct B { int n; } b; // expected-note 2{{here}}
613f4a2713aSLionel Sambuc     static B bs;
614f4a2713aSLionel Sambuc     void f(); // expected-note {{here}}
615f4a2713aSLionel Sambuc     static void sf();
616f4a2713aSLionel Sambuc   };
617f4a2713aSLionel Sambuc   struct C : A {};
618f4a2713aSLionel Sambuc   struct D : A {
gdr161::D619f4a2713aSLionel Sambuc     void g(C c) {
620f4a2713aSLionel Sambuc       (void)b.n;
621f4a2713aSLionel Sambuc       B b1;
622f4a2713aSLionel Sambuc       C::B b2; // ok, accessible as a member of A
623f4a2713aSLionel Sambuc       (void)&C::b; // expected-error {{protected}}
624f4a2713aSLionel Sambuc       (void)&C::bs;
625f4a2713aSLionel Sambuc       (void)c.b; // expected-error {{protected}}
626f4a2713aSLionel Sambuc       (void)c.bs;
627f4a2713aSLionel Sambuc       f();
628f4a2713aSLionel Sambuc       sf();
629f4a2713aSLionel Sambuc       c.f(); // expected-error {{protected}}
630f4a2713aSLionel Sambuc       c.sf();
631f4a2713aSLionel Sambuc       A::f();
632f4a2713aSLionel Sambuc       D::f();
633f4a2713aSLionel Sambuc       A::sf();
634f4a2713aSLionel Sambuc       C::sf();
635f4a2713aSLionel Sambuc       D::sf();
636f4a2713aSLionel Sambuc     }
637f4a2713aSLionel Sambuc   };
638f4a2713aSLionel Sambuc }
639f4a2713aSLionel Sambuc 
640f4a2713aSLionel Sambuc namespace dr162 { // dr162: no
641f4a2713aSLionel Sambuc   struct A {
642f4a2713aSLionel Sambuc     char &f(char);
643f4a2713aSLionel Sambuc     static int &f(int);
644f4a2713aSLionel Sambuc 
gdr162::A645f4a2713aSLionel Sambuc     void g() {
646f4a2713aSLionel Sambuc       int &a = (&A::f)(0); // FIXME: expected-error {{could not be resolved}}
647f4a2713aSLionel Sambuc       char &b = (&A::f)('0'); // expected-error {{could not be resolved}}
648f4a2713aSLionel Sambuc     }
649f4a2713aSLionel Sambuc   };
650f4a2713aSLionel Sambuc 
651f4a2713aSLionel Sambuc   int &c = (&A::f)(0); // FIXME: expected-error {{could not be resolved}}
652f4a2713aSLionel Sambuc   char &d = (&A::f)('0'); // expected-error {{could not be resolved}}
653f4a2713aSLionel Sambuc }
654f4a2713aSLionel Sambuc 
655f4a2713aSLionel Sambuc // dr163: na
656f4a2713aSLionel Sambuc 
657f4a2713aSLionel Sambuc namespace dr164 { // dr164: yes
658f4a2713aSLionel Sambuc   void f(int);
g(T t)659f4a2713aSLionel Sambuc   template <class T> int g(T t) { return f(t); }
660f4a2713aSLionel Sambuc 
661f4a2713aSLionel Sambuc   enum E { e };
662f4a2713aSLionel Sambuc   int f(E);
663f4a2713aSLionel Sambuc 
664f4a2713aSLionel Sambuc   int k = g(e);
665f4a2713aSLionel Sambuc }
666f4a2713aSLionel Sambuc 
667f4a2713aSLionel Sambuc namespace dr165 { // dr165: no
668f4a2713aSLionel Sambuc   namespace N {
669f4a2713aSLionel Sambuc     struct A { friend struct B; };
f()670f4a2713aSLionel Sambuc     void f() { void g(); }
671f4a2713aSLionel Sambuc   }
672f4a2713aSLionel Sambuc   // FIXME: dr1477 says this is ok, dr165 says it's ill-formed
673f4a2713aSLionel Sambuc   struct N::B {};
674f4a2713aSLionel Sambuc   // FIXME: dr165 says this is ill-formed, but the argument in dr1477 says it's ok
g()675f4a2713aSLionel Sambuc   void N::g() {}
676f4a2713aSLionel Sambuc }
677f4a2713aSLionel Sambuc 
678f4a2713aSLionel Sambuc namespace dr166 { // dr166: yes
679f4a2713aSLionel Sambuc   namespace A { class X; }
680f4a2713aSLionel Sambuc 
f(T t)681f4a2713aSLionel Sambuc   template<typename T> int f(T t) { return t.n; }
682f4a2713aSLionel Sambuc   int g(A::X);
h(T t)683f4a2713aSLionel Sambuc   template<typename T> int h(T t) { return t.n; } // expected-error {{private}}
684f4a2713aSLionel Sambuc   int i(A::X);
685f4a2713aSLionel Sambuc 
686f4a2713aSLionel Sambuc   namespace A {
687f4a2713aSLionel Sambuc     class X {
688f4a2713aSLionel Sambuc       friend int f<X>(X);
689f4a2713aSLionel Sambuc       friend int dr166::g(X);
690f4a2713aSLionel Sambuc       friend int h(X);
691f4a2713aSLionel Sambuc       friend int i(X);
692f4a2713aSLionel Sambuc       int n; // expected-note 2{{here}}
693f4a2713aSLionel Sambuc     };
694f4a2713aSLionel Sambuc 
h(X x)695f4a2713aSLionel Sambuc     int h(X x) { return x.n; }
i(X x)696f4a2713aSLionel Sambuc     int i(X x) { return x.n; }
697f4a2713aSLionel Sambuc   }
698f4a2713aSLionel Sambuc 
699f4a2713aSLionel Sambuc   template int f(A::X);
g(A::X x)700f4a2713aSLionel Sambuc   int g(A::X x) { return x.n; }
701f4a2713aSLionel Sambuc   template int h(A::X); // expected-note {{instantiation}}
i(A::X x)702f4a2713aSLionel Sambuc   int i(A::X x) { return x.n; } // expected-error {{private}}
703f4a2713aSLionel Sambuc }
704f4a2713aSLionel Sambuc 
705f4a2713aSLionel Sambuc // dr167: sup 1012
706f4a2713aSLionel Sambuc 
707f4a2713aSLionel Sambuc namespace dr168 { // dr168: no
708f4a2713aSLionel Sambuc   extern "C" typedef int (*p)();
709f4a2713aSLionel Sambuc   extern "C++" typedef int (*q)();
710f4a2713aSLionel Sambuc   struct S {
711f4a2713aSLionel Sambuc     static int f();
712f4a2713aSLionel Sambuc   };
713f4a2713aSLionel Sambuc   p a = &S::f; // FIXME: this should fail.
714f4a2713aSLionel Sambuc   q b = &S::f;
715f4a2713aSLionel Sambuc }
716f4a2713aSLionel Sambuc 
717f4a2713aSLionel Sambuc namespace dr169 { // dr169: yes
718f4a2713aSLionel Sambuc   template<typename> struct A { int n; };
719f4a2713aSLionel Sambuc   struct B {
720f4a2713aSLionel Sambuc     template<typename> struct C;
721f4a2713aSLionel Sambuc     template<typename> void f();
722f4a2713aSLionel Sambuc     template<typename> static int n; // expected-error 0-1{{extension}}
723f4a2713aSLionel Sambuc   };
724f4a2713aSLionel Sambuc   struct D : A<int>, B {
725f4a2713aSLionel Sambuc     using A<int>::n;
726f4a2713aSLionel Sambuc     using B::C<int>; // expected-error {{using declaration cannot refer to a template specialization}}
727f4a2713aSLionel Sambuc     using B::f<int>; // expected-error {{using declaration cannot refer to a template specialization}}
728f4a2713aSLionel Sambuc     using B::n<int>; // expected-error {{using declaration cannot refer to a template specialization}}
729f4a2713aSLionel Sambuc   };
730f4a2713aSLionel Sambuc }
731f4a2713aSLionel Sambuc 
732f4a2713aSLionel Sambuc namespace { // dr171: yes
733f4a2713aSLionel Sambuc   int dr171a;
734f4a2713aSLionel Sambuc }
735f4a2713aSLionel Sambuc int dr171b; // expected-note {{here}}
736f4a2713aSLionel Sambuc namespace dr171 {
737f4a2713aSLionel Sambuc   extern "C" void dr171a();
738f4a2713aSLionel Sambuc   extern "C" void dr171b(); // expected-error {{conflicts}}
739f4a2713aSLionel Sambuc }
740f4a2713aSLionel Sambuc 
741f4a2713aSLionel Sambuc namespace dr172 { // dr172: yes
742f4a2713aSLionel Sambuc   enum { zero };
743f4a2713aSLionel Sambuc   int check1[-1 < zero ? 1 : -1];
744f4a2713aSLionel Sambuc 
745f4a2713aSLionel Sambuc   enum { x = -1, y = (unsigned int)-1 };
746f4a2713aSLionel Sambuc   int check2[sizeof(x) > sizeof(int) ? 1 : -1];
747f4a2713aSLionel Sambuc 
748f4a2713aSLionel Sambuc   enum { a = (unsigned int)-1 / 2 };
749f4a2713aSLionel Sambuc   int check3a[sizeof(a) == sizeof(int) ? 1 : -1];
750f4a2713aSLionel Sambuc   int check3b[-a < 0 ? 1 : -1];
751f4a2713aSLionel Sambuc 
752f4a2713aSLionel Sambuc   enum { b = (unsigned int)-1 / 2 + 1 };
753f4a2713aSLionel Sambuc   int check4a[sizeof(b) == sizeof(unsigned int) ? 1 : -1];
754f4a2713aSLionel Sambuc   int check4b[-b > 0 ? 1 : -1];
755f4a2713aSLionel Sambuc 
756f4a2713aSLionel Sambuc   enum { c = (unsigned long)-1 / 2 };
757f4a2713aSLionel Sambuc   int check5a[sizeof(c) == sizeof(long) ? 1 : -1];
758f4a2713aSLionel Sambuc   int check5b[-c < 0 ? 1 : -1];
759f4a2713aSLionel Sambuc 
760f4a2713aSLionel Sambuc   enum { d = (unsigned long)-1 / 2 + 1 };
761f4a2713aSLionel Sambuc   int check6a[sizeof(d) == sizeof(unsigned long) ? 1 : -1];
762f4a2713aSLionel Sambuc   int check6b[-d > 0 ? 1 : -1];
763f4a2713aSLionel Sambuc 
764f4a2713aSLionel Sambuc   enum { e = (unsigned long long)-1 / 2 }; // expected-error 0-1{{extension}}
765f4a2713aSLionel Sambuc   int check7a[sizeof(e) == sizeof(long) ? 1 : -1]; // expected-error 0-1{{extension}}
766f4a2713aSLionel Sambuc   int check7b[-e < 0 ? 1 : -1];
767f4a2713aSLionel Sambuc 
768f4a2713aSLionel Sambuc   enum { f = (unsigned long long)-1 / 2 + 1 }; // expected-error 0-1{{extension}}
769f4a2713aSLionel Sambuc   int check8a[sizeof(f) == sizeof(unsigned long) ? 1 : -1]; // expected-error 0-1{{extension}}
770f4a2713aSLionel Sambuc   int check8b[-f > 0 ? 1 : -1];
771f4a2713aSLionel Sambuc }
772f4a2713aSLionel Sambuc 
773f4a2713aSLionel Sambuc namespace dr173 { // dr173: yes
774f4a2713aSLionel Sambuc   int check[('0' + 1 == '1' && '0' + 2 == '2' && '0' + 3 == '3' &&
775f4a2713aSLionel Sambuc              '0' + 4 == '4' && '0' + 5 == '5' && '0' + 6 == '6' &&
776f4a2713aSLionel Sambuc              '0' + 7 == '7' && '0' + 8 == '8' && '0' + 9 == '9') ? 1 : -1];
777f4a2713aSLionel Sambuc }
778f4a2713aSLionel Sambuc 
779f4a2713aSLionel Sambuc // dr174: sup 1012
780f4a2713aSLionel Sambuc 
781f4a2713aSLionel Sambuc namespace dr175 { // dr175: yes
782f4a2713aSLionel Sambuc   struct A {}; // expected-note {{here}}
783f4a2713aSLionel Sambuc   struct B : private A {}; // expected-note {{constrained by private inheritance}}
784f4a2713aSLionel Sambuc   struct C : B {
785f4a2713aSLionel Sambuc     A a; // expected-error {{private}}
786f4a2713aSLionel Sambuc     dr175::A b;
787f4a2713aSLionel Sambuc   };
788f4a2713aSLionel Sambuc }
789f4a2713aSLionel Sambuc 
790f4a2713aSLionel Sambuc namespace dr176 { // dr176: yes
791f4a2713aSLionel Sambuc   template<typename T> class Y;
792f4a2713aSLionel Sambuc   template<> class Y<int> {
f()793f4a2713aSLionel Sambuc     void f() {
794f4a2713aSLionel Sambuc       typedef Y A; // expected-note {{here}}
795f4a2713aSLionel Sambuc       typedef Y<char> A; // expected-error {{different types ('Y<char>' vs 'Y<int>')}}
796f4a2713aSLionel Sambuc     }
797f4a2713aSLionel Sambuc   };
798f4a2713aSLionel Sambuc 
799f4a2713aSLionel Sambuc   template<typename T> struct Base {}; // expected-note 2{{found}}
800f4a2713aSLionel Sambuc   template<typename T> struct Derived : public Base<T> {
fdr176::Derived801f4a2713aSLionel Sambuc     void f() {
802f4a2713aSLionel Sambuc       typedef typename Derived::template Base<T> A;
803f4a2713aSLionel Sambuc       typedef typename Derived::Base A;
804f4a2713aSLionel Sambuc     }
805f4a2713aSLionel Sambuc   };
806f4a2713aSLionel Sambuc   template struct Derived<int>;
807f4a2713aSLionel Sambuc 
808f4a2713aSLionel Sambuc   template<typename T> struct Derived2 : Base<int>, Base<char> {
809f4a2713aSLionel Sambuc     typename Derived2::Base b; // expected-error {{found in multiple base classes}}
810f4a2713aSLionel Sambuc     typename Derived2::Base<double> d;
811f4a2713aSLionel Sambuc   };
812f4a2713aSLionel Sambuc 
813f4a2713aSLionel Sambuc   template<typename T> class X { // expected-note {{here}}
814f4a2713aSLionel Sambuc     X *p1;
815f4a2713aSLionel Sambuc     X<T> *p2;
816f4a2713aSLionel Sambuc     X<int> *p3;
817f4a2713aSLionel Sambuc     dr176::X *p4; // expected-error {{requires template arguments}}
818f4a2713aSLionel Sambuc   };
819f4a2713aSLionel Sambuc }
820f4a2713aSLionel Sambuc 
821f4a2713aSLionel Sambuc namespace dr177 { // dr177: yes
822f4a2713aSLionel Sambuc   struct B {};
823f4a2713aSLionel Sambuc   struct A {
824f4a2713aSLionel Sambuc     A(A &); // expected-note {{not viable: expects an l-value}}
825f4a2713aSLionel Sambuc     A(const B &);
826f4a2713aSLionel Sambuc   };
827f4a2713aSLionel Sambuc   B b;
828f4a2713aSLionel Sambuc   A a = b; // expected-error {{no viable constructor copying variable}}
829f4a2713aSLionel Sambuc }
830f4a2713aSLionel Sambuc 
831f4a2713aSLionel Sambuc namespace dr178 { // dr178: yes
832f4a2713aSLionel Sambuc   int check[int() == 0 ? 1 : -1];
833f4a2713aSLionel Sambuc #if __cplusplus >= 201103L
834f4a2713aSLionel Sambuc   static_assert(int{} == 0, "");
835f4a2713aSLionel Sambuc   struct S { int a, b; };
836f4a2713aSLionel Sambuc   static_assert(S{1}.b == 0, "");
Tdr178::T837f4a2713aSLionel Sambuc   struct T { constexpr T() : n() {} int n; };
838f4a2713aSLionel Sambuc   static_assert(T().n == 0, "");
Udr178::U839f4a2713aSLionel Sambuc   struct U : S { constexpr U() : S() {} };
840f4a2713aSLionel Sambuc   static_assert(U().b == 0, "");
841f4a2713aSLionel Sambuc #endif
842f4a2713aSLionel Sambuc }
843f4a2713aSLionel Sambuc 
844f4a2713aSLionel Sambuc namespace dr179 { // dr179: yes
845f4a2713aSLionel Sambuc   void f();
846f4a2713aSLionel Sambuc   int n = &f - &f; // expected-error {{arithmetic on pointers to the function type 'void ()'}}
847f4a2713aSLionel Sambuc }
848f4a2713aSLionel Sambuc 
849f4a2713aSLionel Sambuc namespace dr180 { // dr180: yes
850f4a2713aSLionel Sambuc   template<typename T> struct X : T, T::some_base {
Xdr180::X851f4a2713aSLionel Sambuc     X() : T::some_type_that_might_be_T(), T::some_base() {}
852f4a2713aSLionel Sambuc     friend class T::some_class;
fdr180::X853f4a2713aSLionel Sambuc     void f() {
854f4a2713aSLionel Sambuc       enum T::some_enum e;
855f4a2713aSLionel Sambuc     }
856f4a2713aSLionel Sambuc   };
857f4a2713aSLionel Sambuc }
858f4a2713aSLionel Sambuc 
859f4a2713aSLionel Sambuc namespace dr181 { // dr181: yes
860f4a2713aSLionel Sambuc   namespace X {
861f4a2713aSLionel Sambuc     template <template X<class T> > struct A { }; // expected-error +{{}}
862f4a2713aSLionel Sambuc     template <template X<class T> > void f(A<X>) { } // expected-error +{{}}
863f4a2713aSLionel Sambuc   }
864f4a2713aSLionel Sambuc 
865f4a2713aSLionel Sambuc   namespace Y {
866f4a2713aSLionel Sambuc     template <template <class T> class X> struct A { };
867f4a2713aSLionel Sambuc     template <template <class T> class X> void f(A<X>) { }
868f4a2713aSLionel Sambuc   }
869f4a2713aSLionel Sambuc }
870f4a2713aSLionel Sambuc 
871f4a2713aSLionel Sambuc namespace dr182 { // dr182: yes
872f4a2713aSLionel Sambuc   template <class T> struct C {
873f4a2713aSLionel Sambuc     void f();
874f4a2713aSLionel Sambuc     void g();
875f4a2713aSLionel Sambuc   };
876f4a2713aSLionel Sambuc 
877f4a2713aSLionel Sambuc   template <class T> void C<T>::f() {}
878f4a2713aSLionel Sambuc   template <class T> void C<T>::g() {}
879f4a2713aSLionel Sambuc 
880f4a2713aSLionel Sambuc   class A {
881f4a2713aSLionel Sambuc     class B {}; // expected-note {{here}}
882f4a2713aSLionel Sambuc     void f();
883f4a2713aSLionel Sambuc   };
884f4a2713aSLionel Sambuc 
885f4a2713aSLionel Sambuc   template void C<A::B>::f();
886f4a2713aSLionel Sambuc   template <> void C<A::B>::g(); // expected-error {{private}}
887f4a2713aSLionel Sambuc 
888f4a2713aSLionel Sambuc   void A::f() {
889f4a2713aSLionel Sambuc     C<B> cb;
890f4a2713aSLionel Sambuc     cb.f();
891f4a2713aSLionel Sambuc   }
892f4a2713aSLionel Sambuc }
893f4a2713aSLionel Sambuc 
894f4a2713aSLionel Sambuc namespace dr183 { // dr183: sup 382
895f4a2713aSLionel Sambuc   template<typename T> struct A {};
896f4a2713aSLionel Sambuc   template<typename T> struct B {
897f4a2713aSLionel Sambuc     typedef int X;
898f4a2713aSLionel Sambuc   };
899f4a2713aSLionel Sambuc   template<> struct A<int> {
900f4a2713aSLionel Sambuc     typename B<int>::X x;
901f4a2713aSLionel Sambuc   };
902f4a2713aSLionel Sambuc }
903f4a2713aSLionel Sambuc 
904f4a2713aSLionel Sambuc namespace dr184 { // dr184: yes
905f4a2713aSLionel Sambuc   template<typename T = float> struct B {};
906f4a2713aSLionel Sambuc 
907f4a2713aSLionel Sambuc   template<template<typename TT = float> class T> struct A {
908f4a2713aSLionel Sambuc     void f();
909f4a2713aSLionel Sambuc     void g();
910f4a2713aSLionel Sambuc   };
911f4a2713aSLionel Sambuc 
912f4a2713aSLionel Sambuc   template<template<typename TT> class T> void A<T>::f() { // expected-note {{here}}
913f4a2713aSLionel Sambuc     T<> t; // expected-error {{too few template arguments}}
914f4a2713aSLionel Sambuc   }
915f4a2713aSLionel Sambuc 
916f4a2713aSLionel Sambuc   template<template<typename TT = char> class T> void A<T>::g() {
917f4a2713aSLionel Sambuc     T<> t;
918f4a2713aSLionel Sambuc     typedef T<> X;
919f4a2713aSLionel Sambuc     typedef T<char> X;
920f4a2713aSLionel Sambuc   }
921f4a2713aSLionel Sambuc 
922f4a2713aSLionel Sambuc   void h() { A<B>().g(); }
923f4a2713aSLionel Sambuc }
924f4a2713aSLionel Sambuc 
925f4a2713aSLionel Sambuc // dr185 FIXME: add codegen test
926f4a2713aSLionel Sambuc 
927f4a2713aSLionel Sambuc namespace dr187 { // dr187: sup 481
928f4a2713aSLionel Sambuc   const int Z = 1;
929f4a2713aSLionel Sambuc   template<int X = Z, int Z = X> struct A;
930f4a2713aSLionel Sambuc   typedef A<> T;
931f4a2713aSLionel Sambuc   typedef A<1, 1> T;
932f4a2713aSLionel Sambuc }
933f4a2713aSLionel Sambuc 
934f4a2713aSLionel Sambuc namespace dr188 { // dr188: yes
935f4a2713aSLionel Sambuc   char c[10];
936f4a2713aSLionel Sambuc   int check[sizeof(0, c) == 10 ? 1 : -1];
937f4a2713aSLionel Sambuc }
938f4a2713aSLionel Sambuc 
939f4a2713aSLionel Sambuc // dr190 FIXME: add codegen test for tbaa
940f4a2713aSLionel Sambuc 
941f4a2713aSLionel Sambuc // dr193 FIXME: add codegen test
942f4a2713aSLionel Sambuc 
943f4a2713aSLionel Sambuc namespace dr194 { // dr194: yes
944f4a2713aSLionel Sambuc   struct A {
945f4a2713aSLionel Sambuc     A();
946f4a2713aSLionel Sambuc     void A(); // expected-error {{has the same name as its class}} expected-error {{constructor cannot have a return type}}
947f4a2713aSLionel Sambuc   };
948f4a2713aSLionel Sambuc   struct B {
949f4a2713aSLionel Sambuc     void B(); // expected-error {{has the same name as its class}} expected-error {{constructor cannot have a return type}}
950f4a2713aSLionel Sambuc     B();
951f4a2713aSLionel Sambuc   };
952f4a2713aSLionel Sambuc   struct C {
953f4a2713aSLionel Sambuc     inline explicit C(int) {}
954f4a2713aSLionel Sambuc   };
955f4a2713aSLionel Sambuc }
956f4a2713aSLionel Sambuc 
957f4a2713aSLionel Sambuc namespace dr195 { // dr195: yes
958f4a2713aSLionel Sambuc   void f();
959f4a2713aSLionel Sambuc   int *p = (int*)&f; // expected-error 0-1{{extension}}
960f4a2713aSLionel Sambuc   void (*q)() = (void(*)())&p; // expected-error 0-1{{extension}}
961f4a2713aSLionel Sambuc }
962f4a2713aSLionel Sambuc 
963f4a2713aSLionel Sambuc namespace dr197 { // dr197: yes
964f4a2713aSLionel Sambuc   char &f(char);
965f4a2713aSLionel Sambuc 
966f4a2713aSLionel Sambuc   template <class T> void g(T t) {
967f4a2713aSLionel Sambuc     char &a = f(1);
968f4a2713aSLionel Sambuc     char &b = f(T(1)); // expected-error {{unrelated type 'int'}}
969f4a2713aSLionel Sambuc     char &c = f(t); // expected-error {{unrelated type 'int'}}
970f4a2713aSLionel Sambuc   }
971f4a2713aSLionel Sambuc 
972f4a2713aSLionel Sambuc   void f(int);
973f4a2713aSLionel Sambuc 
974f4a2713aSLionel Sambuc   enum E { e };
975f4a2713aSLionel Sambuc   int &f(E);
976f4a2713aSLionel Sambuc 
977f4a2713aSLionel Sambuc   void h() {
978f4a2713aSLionel Sambuc     g('a');
979f4a2713aSLionel Sambuc     g(2);
980f4a2713aSLionel Sambuc     g(e); // expected-note {{in instantiation of}}
981f4a2713aSLionel Sambuc   }
982f4a2713aSLionel Sambuc }
983f4a2713aSLionel Sambuc 
984f4a2713aSLionel Sambuc namespace dr198 { // dr198: yes
985f4a2713aSLionel Sambuc   struct A {
986f4a2713aSLionel Sambuc     int n;
987f4a2713aSLionel Sambuc     struct B {
988f4a2713aSLionel Sambuc       int m[sizeof(n)];
989f4a2713aSLionel Sambuc #if __cplusplus < 201103L
990f4a2713aSLionel Sambuc       // expected-error@-2 {{invalid use of non-static data member}}
991f4a2713aSLionel Sambuc #endif
992f4a2713aSLionel Sambuc       int f() { return n; }
993f4a2713aSLionel Sambuc       // expected-error@-1 {{use of non-static data member 'n' of 'A' from nested type 'B'}}
994f4a2713aSLionel Sambuc     };
995f4a2713aSLionel Sambuc     struct C;
996f4a2713aSLionel Sambuc     struct D;
997f4a2713aSLionel Sambuc   };
998f4a2713aSLionel Sambuc   struct A::C {
999f4a2713aSLionel Sambuc     int m[sizeof(n)];
1000f4a2713aSLionel Sambuc #if __cplusplus < 201103L
1001f4a2713aSLionel Sambuc     // expected-error@-2 {{invalid use of non-static data member}}
1002f4a2713aSLionel Sambuc #endif
1003f4a2713aSLionel Sambuc     int f() { return n; }
1004f4a2713aSLionel Sambuc     // expected-error@-1 {{use of non-static data member 'n' of 'A' from nested type 'C'}}
1005f4a2713aSLionel Sambuc   };
1006f4a2713aSLionel Sambuc   struct A::D : A {
1007f4a2713aSLionel Sambuc     int m[sizeof(n)];
1008f4a2713aSLionel Sambuc #if __cplusplus < 201103L
1009f4a2713aSLionel Sambuc     // expected-error@-2 {{invalid use of non-static data member}}
1010f4a2713aSLionel Sambuc #endif
1011f4a2713aSLionel Sambuc     int f() { return n; }
1012f4a2713aSLionel Sambuc   };
1013f4a2713aSLionel Sambuc }
1014f4a2713aSLionel Sambuc 
1015f4a2713aSLionel Sambuc // dr199 FIXME: add codegen test
1016