xref: /minix3/external/bsd/llvm/dist/clang/test/CXX/drs/dr2xx.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
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 // PR13819 -- __SIZE_TYPE__ is incompatible.
7*0a6a1f1dSLionel Sambuc typedef __SIZE_TYPE__ size_t; // expected-error 0-1 {{extension}}
8f4a2713aSLionel Sambuc 
9f4a2713aSLionel Sambuc #if __cplusplus < 201103L
10f4a2713aSLionel Sambuc #define fold(x) (__builtin_constant_p(x) ? (x) : (x))
11f4a2713aSLionel Sambuc #else
12f4a2713aSLionel Sambuc #define fold
13f4a2713aSLionel Sambuc #endif
14f4a2713aSLionel Sambuc 
15f4a2713aSLionel Sambuc namespace dr200 { // dr200: dup 214
16f4a2713aSLionel Sambuc   template <class T> T f(int);
17f4a2713aSLionel Sambuc   template <class T, class U> T f(U) = delete; // expected-error 0-1{{extension}}
18f4a2713aSLionel Sambuc 
g()19f4a2713aSLionel Sambuc   void g() {
20f4a2713aSLionel Sambuc     f<int>(1);
21f4a2713aSLionel Sambuc   }
22f4a2713aSLionel Sambuc }
23f4a2713aSLionel Sambuc 
24f4a2713aSLionel Sambuc // dr201 FIXME: write codegen test
25f4a2713aSLionel Sambuc 
26f4a2713aSLionel Sambuc namespace dr202 { // dr202: yes
27f4a2713aSLionel Sambuc   template<typename T> T f();
28f4a2713aSLionel Sambuc   template<int (*g)()> struct X {
29f4a2713aSLionel Sambuc     int arr[fold(g == &f<int>) ? 1 : -1];
30f4a2713aSLionel Sambuc   };
31f4a2713aSLionel Sambuc   template struct X<f>;
32f4a2713aSLionel Sambuc }
33f4a2713aSLionel Sambuc 
34f4a2713aSLionel Sambuc // FIXME (export) dr204: no
35f4a2713aSLionel Sambuc 
36f4a2713aSLionel Sambuc namespace dr206 { // dr206: yes
37f4a2713aSLionel Sambuc   struct S; // expected-note 2{{declaration}}
38f4a2713aSLionel Sambuc   template<typename T> struct Q { S s; }; // expected-error {{incomplete}}
f()39f4a2713aSLionel Sambuc   template<typename T> void f() { S s; } // expected-error {{incomplete}}
40f4a2713aSLionel Sambuc }
41f4a2713aSLionel Sambuc 
42f4a2713aSLionel Sambuc namespace dr207 { // dr207: yes
43f4a2713aSLionel Sambuc   class A {
44f4a2713aSLionel Sambuc   protected:
f()45f4a2713aSLionel Sambuc     static void f() {}
46f4a2713aSLionel Sambuc   };
47f4a2713aSLionel Sambuc   class B : A {
48f4a2713aSLionel Sambuc   public:
49f4a2713aSLionel Sambuc     using A::f;
g()50f4a2713aSLionel Sambuc     void g() {
51f4a2713aSLionel Sambuc       A::f();
52f4a2713aSLionel Sambuc       f();
53f4a2713aSLionel Sambuc     }
54f4a2713aSLionel Sambuc   };
55f4a2713aSLionel Sambuc }
56f4a2713aSLionel Sambuc 
57f4a2713aSLionel Sambuc // dr208 FIXME: write codegen test
58f4a2713aSLionel Sambuc 
59f4a2713aSLionel Sambuc namespace dr209 { // dr209: yes
60f4a2713aSLionel Sambuc   class A {
61f4a2713aSLionel Sambuc     void f(); // expected-note {{here}}
62f4a2713aSLionel Sambuc   };
63f4a2713aSLionel Sambuc   class B {
64f4a2713aSLionel Sambuc     friend void A::f(); // expected-error {{private}}
65f4a2713aSLionel Sambuc   };
66f4a2713aSLionel Sambuc }
67f4a2713aSLionel Sambuc 
68f4a2713aSLionel Sambuc // dr210 FIXME: write codegen test
69f4a2713aSLionel Sambuc 
70f4a2713aSLionel Sambuc namespace dr211 { // dr211: yes
71f4a2713aSLionel Sambuc   struct A {
Adr211::A72f4a2713aSLionel Sambuc     A() try {
73f4a2713aSLionel Sambuc       throw 0;
74f4a2713aSLionel Sambuc     } catch (...) {
75f4a2713aSLionel Sambuc       return; // expected-error {{return in the catch of a function try block of a constructor}}
76f4a2713aSLionel Sambuc     }
77f4a2713aSLionel Sambuc   };
78f4a2713aSLionel Sambuc }
79f4a2713aSLionel Sambuc 
80f4a2713aSLionel Sambuc namespace dr213 { // dr213: yes
81f4a2713aSLionel Sambuc   template <class T> struct A : T {
hdr213::A82f4a2713aSLionel Sambuc     void h(T t) {
83f4a2713aSLionel Sambuc       char &r1 = f(t);
84f4a2713aSLionel Sambuc       int &r2 = g(t); // expected-error {{undeclared}}
85f4a2713aSLionel Sambuc     }
86f4a2713aSLionel Sambuc   };
87f4a2713aSLionel Sambuc   struct B {
88f4a2713aSLionel Sambuc     int &f(B);
89f4a2713aSLionel Sambuc     int &g(B); // expected-note {{in dependent base class}}
90f4a2713aSLionel Sambuc   };
91f4a2713aSLionel Sambuc   char &f(B);
92f4a2713aSLionel Sambuc 
93f4a2713aSLionel Sambuc   template void A<B>::h(B); // expected-note {{instantiation}}
94f4a2713aSLionel Sambuc }
95f4a2713aSLionel Sambuc 
96f4a2713aSLionel Sambuc namespace dr214 { // dr214: yes
checked_cast(U from)97f4a2713aSLionel Sambuc   template<typename T, typename U> T checked_cast(U from) { U::error; }
98f4a2713aSLionel Sambuc   template<typename T, typename U> T checked_cast(U *from);
99f4a2713aSLionel Sambuc   class C {};
foo(int * arg)100f4a2713aSLionel Sambuc   void foo(int *arg) { checked_cast<const C *>(arg); }
101f4a2713aSLionel Sambuc 
102f4a2713aSLionel Sambuc   template<typename T> T f(int);
f(U)103f4a2713aSLionel Sambuc   template<typename T, typename U> T f(U) { T::error; }
g()104f4a2713aSLionel Sambuc   void g() {
105f4a2713aSLionel Sambuc     f<int>(1);
106f4a2713aSLionel Sambuc   }
107f4a2713aSLionel Sambuc }
108f4a2713aSLionel Sambuc 
109f4a2713aSLionel Sambuc namespace dr215 { // dr215: yes
110f4a2713aSLionel Sambuc   template<typename T> class X {
111f4a2713aSLionel Sambuc     friend void T::foo();
112f4a2713aSLionel Sambuc     int n;
113f4a2713aSLionel Sambuc   };
114f4a2713aSLionel Sambuc   struct Y {
foodr215::Y115f4a2713aSLionel Sambuc     void foo() { (void)+X<Y>().n; }
116f4a2713aSLionel Sambuc   };
117f4a2713aSLionel Sambuc }
118f4a2713aSLionel Sambuc 
119f4a2713aSLionel Sambuc namespace dr216 { // dr216: no
120f4a2713aSLionel Sambuc   // FIXME: Should reject this: 'f' has linkage but its type does not,
121f4a2713aSLionel Sambuc   // and 'f' is odr-used but not defined in this TU.
122f4a2713aSLionel Sambuc   typedef enum { e } *E;
123f4a2713aSLionel Sambuc   void f(E);
g(E e)124f4a2713aSLionel Sambuc   void g(E e) { f(e); }
125f4a2713aSLionel Sambuc 
126f4a2713aSLionel Sambuc   struct S {
127f4a2713aSLionel Sambuc     // FIXME: Should reject this: 'f' has linkage but its type does not,
128f4a2713aSLionel Sambuc     // and 'f' is odr-used but not defined in this TU.
129f4a2713aSLionel Sambuc     typedef enum { e } *E;
130f4a2713aSLionel Sambuc     void f(E);
131f4a2713aSLionel Sambuc   };
g(S s,S::E e)132f4a2713aSLionel Sambuc   void g(S s, S::E e) { s.f(e); }
133f4a2713aSLionel Sambuc }
134f4a2713aSLionel Sambuc 
135f4a2713aSLionel Sambuc namespace dr217 { // dr217: yes
136f4a2713aSLionel Sambuc   template<typename T> struct S {
137f4a2713aSLionel Sambuc     void f(int);
138f4a2713aSLionel Sambuc   };
f(int=0)139f4a2713aSLionel Sambuc   template<typename T> void S<T>::f(int = 0) {} // expected-error {{default arguments cannot be added}}
140f4a2713aSLionel Sambuc }
141f4a2713aSLionel Sambuc 
142f4a2713aSLionel Sambuc namespace dr218 { // dr218: yes
143f4a2713aSLionel Sambuc   namespace A {
144f4a2713aSLionel Sambuc     struct S {};
145f4a2713aSLionel Sambuc     void f(S);
146f4a2713aSLionel Sambuc   }
147f4a2713aSLionel Sambuc   namespace B {
148f4a2713aSLionel Sambuc     struct S {};
149f4a2713aSLionel Sambuc     void f(S);
150f4a2713aSLionel Sambuc   }
151f4a2713aSLionel Sambuc 
152f4a2713aSLionel Sambuc   struct C {
153f4a2713aSLionel Sambuc     int f;
test1dr218::C154f4a2713aSLionel Sambuc     void test1(A::S as) { f(as); } // expected-error {{called object type 'int'}}
test2dr218::C155f4a2713aSLionel Sambuc     void test2(A::S as) { void f(); f(as); } // expected-error {{too many arguments}} expected-note {{}}
test3dr218::C156f4a2713aSLionel Sambuc     void test3(A::S as) { using A::f; f(as); } // ok
test4dr218::C157f4a2713aSLionel Sambuc     void test4(A::S as) { using B::f; f(as); } // ok
test5dr218::C158f4a2713aSLionel Sambuc     void test5(A::S as) { int f; f(as); } // expected-error {{called object type 'int'}}
test6dr218::C159f4a2713aSLionel Sambuc     void test6(A::S as) { struct f {}; (void) f(as); } // expected-error {{no matching conversion}} expected-note +{{}}
160f4a2713aSLionel Sambuc   };
161f4a2713aSLionel Sambuc 
162f4a2713aSLionel Sambuc   namespace D {
163f4a2713aSLionel Sambuc     struct S {};
164f4a2713aSLionel Sambuc     struct X { void operator()(S); } f;
165f4a2713aSLionel Sambuc   }
testD(D::S ds)166f4a2713aSLionel Sambuc   void testD(D::S ds) { f(ds); } // expected-error {{undeclared identifier}}
167f4a2713aSLionel Sambuc 
168f4a2713aSLionel Sambuc   namespace E {
169f4a2713aSLionel Sambuc     struct S {};
170f4a2713aSLionel Sambuc     struct f { f(S); };
171f4a2713aSLionel Sambuc   }
testE(E::S es)172f4a2713aSLionel Sambuc   void testE(E::S es) { f(es); } // expected-error {{undeclared identifier}}
173f4a2713aSLionel Sambuc 
174f4a2713aSLionel Sambuc   namespace F {
175f4a2713aSLionel Sambuc     struct S {
f(S,T)176f4a2713aSLionel Sambuc       template<typename T> friend void f(S, T) {}
177f4a2713aSLionel Sambuc     };
178f4a2713aSLionel Sambuc   }
testF(F::S fs)179f4a2713aSLionel Sambuc   void testF(F::S fs) { f(fs, 0); }
180f4a2713aSLionel Sambuc 
181f4a2713aSLionel Sambuc   namespace G {
182f4a2713aSLionel Sambuc     namespace X {
183f4a2713aSLionel Sambuc       int f;
184f4a2713aSLionel Sambuc       struct A {};
185f4a2713aSLionel Sambuc     }
186f4a2713aSLionel Sambuc     namespace Y {
187f4a2713aSLionel Sambuc       template<typename T> void f(T);
188f4a2713aSLionel Sambuc       struct B {};
189f4a2713aSLionel Sambuc     }
190f4a2713aSLionel Sambuc     template<typename A, typename B> struct C {};
191f4a2713aSLionel Sambuc   }
testG(G::C<G::X::A,G::Y::B> gc)192f4a2713aSLionel Sambuc   void testG(G::C<G::X::A, G::Y::B> gc) { f(gc); }
193f4a2713aSLionel Sambuc }
194f4a2713aSLionel Sambuc 
195f4a2713aSLionel Sambuc // dr219: na
196f4a2713aSLionel Sambuc // dr220: na
197f4a2713aSLionel Sambuc 
198f4a2713aSLionel Sambuc namespace dr221 { // dr221: yes
199*0a6a1f1dSLionel Sambuc   struct A { // expected-note 2-4{{candidate}}
200*0a6a1f1dSLionel Sambuc     A &operator=(int&); // expected-note 2{{candidate}}
201f4a2713aSLionel Sambuc     A &operator+=(int&);
202f4a2713aSLionel Sambuc     static A &operator=(A&, double&); // expected-error {{cannot be a static member}}
203f4a2713aSLionel Sambuc     static A &operator+=(A&, double&); // expected-error {{cannot be a static member}}
204f4a2713aSLionel Sambuc     friend A &operator=(A&, char&); // expected-error {{must be a non-static member function}}
205f4a2713aSLionel Sambuc     friend A &operator+=(A&, char&);
206f4a2713aSLionel Sambuc   };
207f4a2713aSLionel Sambuc   A &operator=(A&, float&); // expected-error {{must be a non-static member function}}
208f4a2713aSLionel Sambuc   A &operator+=(A&, float&);
209f4a2713aSLionel Sambuc 
test(A a,int n,char c,float f)210f4a2713aSLionel Sambuc   void test(A a, int n, char c, float f) {
211f4a2713aSLionel Sambuc     a = n;
212f4a2713aSLionel Sambuc     a += n;
213*0a6a1f1dSLionel Sambuc     a = c; // expected-error {{no viable}}
214f4a2713aSLionel Sambuc     a += c;
215*0a6a1f1dSLionel Sambuc     a = f; // expected-error {{no viable}}
216f4a2713aSLionel Sambuc     a += f;
217f4a2713aSLionel Sambuc   }
218f4a2713aSLionel Sambuc }
219f4a2713aSLionel Sambuc 
220*0a6a1f1dSLionel Sambuc namespace dr222 { // dr222: dup 637
f(int a,int b,int c,int * x)221*0a6a1f1dSLionel Sambuc   void f(int a, int b, int c, int *x) {
222*0a6a1f1dSLionel Sambuc #pragma clang diagnostic push
223*0a6a1f1dSLionel Sambuc #pragma clang diagnostic warning "-Wunsequenced"
224*0a6a1f1dSLionel Sambuc     void((a += b) += c);
225*0a6a1f1dSLionel Sambuc     void((a += b) + (a += c)); // expected-warning {{multiple unsequenced modifications to 'a'}}
226*0a6a1f1dSLionel Sambuc 
227*0a6a1f1dSLionel Sambuc     x[a++] = a; // expected-warning {{unsequenced modification and access to 'a'}}
228*0a6a1f1dSLionel Sambuc 
229*0a6a1f1dSLionel Sambuc     a = b = 0; // ok, read and write of 'b' are sequenced
230*0a6a1f1dSLionel Sambuc 
231*0a6a1f1dSLionel Sambuc     a = (b = a++); // expected-warning {{multiple unsequenced modifications to 'a'}}
232*0a6a1f1dSLionel Sambuc     a = (b = ++a);
233*0a6a1f1dSLionel Sambuc #pragma clang diagnostic pop
234*0a6a1f1dSLionel Sambuc   }
235*0a6a1f1dSLionel Sambuc }
236f4a2713aSLionel Sambuc 
237f4a2713aSLionel Sambuc // dr223: na
238f4a2713aSLionel Sambuc 
239f4a2713aSLionel Sambuc namespace dr224 { // dr224: no
240f4a2713aSLionel Sambuc   namespace example1 {
241f4a2713aSLionel Sambuc     template <class T> class A {
242f4a2713aSLionel Sambuc       typedef int type;
243f4a2713aSLionel Sambuc       A::type a;
244f4a2713aSLionel Sambuc       A<T>::type b;
245f4a2713aSLionel Sambuc       A<T*>::type c; // expected-error {{missing 'typename'}}
246f4a2713aSLionel Sambuc       ::dr224::example1::A<T>::type d;
247f4a2713aSLionel Sambuc 
248f4a2713aSLionel Sambuc       class B {
249f4a2713aSLionel Sambuc         typedef int type;
250f4a2713aSLionel Sambuc 
251f4a2713aSLionel Sambuc         A::type a;
252f4a2713aSLionel Sambuc         A<T>::type b;
253f4a2713aSLionel Sambuc         A<T*>::type c; // expected-error {{missing 'typename'}}
254f4a2713aSLionel Sambuc         ::dr224::example1::A<T>::type d;
255f4a2713aSLionel Sambuc 
256f4a2713aSLionel Sambuc         B::type e;
257f4a2713aSLionel Sambuc         A<T>::B::type f;
258f4a2713aSLionel Sambuc         A<T*>::B::type g; // expected-error {{missing 'typename'}}
259f4a2713aSLionel Sambuc         typename A<T*>::B::type h;
260f4a2713aSLionel Sambuc       };
261f4a2713aSLionel Sambuc     };
262f4a2713aSLionel Sambuc 
263f4a2713aSLionel Sambuc     template <class T> class A<T*> {
264f4a2713aSLionel Sambuc       typedef int type;
265f4a2713aSLionel Sambuc       A<T*>::type a;
266f4a2713aSLionel Sambuc       A<T>::type b; // expected-error {{missing 'typename'}}
267f4a2713aSLionel Sambuc     };
268f4a2713aSLionel Sambuc 
269f4a2713aSLionel Sambuc     template <class T1, class T2, int I> struct B {
270f4a2713aSLionel Sambuc       typedef int type;
271f4a2713aSLionel Sambuc       B<T1, T2, I>::type b1;
272f4a2713aSLionel Sambuc       B<T2, T1, I>::type b2; // expected-error {{missing 'typename'}}
273f4a2713aSLionel Sambuc 
274f4a2713aSLionel Sambuc       typedef T1 my_T1;
275f4a2713aSLionel Sambuc       static const int my_I = I;
276f4a2713aSLionel Sambuc       static const int my_I2 = I+0;
277f4a2713aSLionel Sambuc       static const int my_I3 = my_I;
278f4a2713aSLionel Sambuc       B<my_T1, T2, my_I>::type b3; // FIXME: expected-error {{missing 'typename'}}
279f4a2713aSLionel Sambuc       B<my_T1, T2, my_I2>::type b4; // expected-error {{missing 'typename'}}
280f4a2713aSLionel Sambuc       B<my_T1, T2, my_I3>::type b5; // FIXME: expected-error {{missing 'typename'}}
281f4a2713aSLionel Sambuc     };
282f4a2713aSLionel Sambuc   }
283f4a2713aSLionel Sambuc 
284f4a2713aSLionel Sambuc   namespace example2 {
285f4a2713aSLionel Sambuc     template <int, typename T> struct X { typedef T type; };
286f4a2713aSLionel Sambuc     template <class T> class A {
287f4a2713aSLionel Sambuc       static const int i = 5;
288f4a2713aSLionel Sambuc       X<i, int>::type w; // FIXME: expected-error {{missing 'typename'}}
289f4a2713aSLionel Sambuc       X<A::i, char>::type x; // FIXME: expected-error {{missing 'typename'}}
290f4a2713aSLionel Sambuc       X<A<T>::i, double>::type y; // FIXME: expected-error {{missing 'typename'}}
291f4a2713aSLionel Sambuc       X<A<T*>::i, long>::type z; // expected-error {{missing 'typename'}}
292f4a2713aSLionel Sambuc       int f();
293f4a2713aSLionel Sambuc     };
f()294f4a2713aSLionel Sambuc     template <class T> int A<T>::f() {
295f4a2713aSLionel Sambuc       return i;
296f4a2713aSLionel Sambuc     }
297f4a2713aSLionel Sambuc   }
298f4a2713aSLionel Sambuc }
299f4a2713aSLionel Sambuc 
300f4a2713aSLionel Sambuc // dr225: yes
dr225_f(T t)301f4a2713aSLionel Sambuc template<typename T> void dr225_f(T t) { dr225_g(t); } // expected-error {{call to function 'dr225_g' that is neither visible in the template definition nor found by argument-dependent lookup}}
302f4a2713aSLionel Sambuc void dr225_g(int); // expected-note {{should be declared prior to the call site}}
303f4a2713aSLionel Sambuc template void dr225_f(int); // expected-note {{in instantiation of}}
304f4a2713aSLionel Sambuc 
305f4a2713aSLionel Sambuc namespace dr226 { // dr226: no
f()306f4a2713aSLionel Sambuc   template<typename T = void> void f() {}
307f4a2713aSLionel Sambuc #if __cplusplus < 201103L
308f4a2713aSLionel Sambuc   // expected-error@-2 {{extension}}
309f4a2713aSLionel Sambuc   // FIXME: This appears to be wrong: default arguments for function templates
310f4a2713aSLionel Sambuc   // are listed as a defect (in c++98) not an extension. EDG accepts them in
311f4a2713aSLionel Sambuc   // strict c++98 mode.
312f4a2713aSLionel Sambuc #endif
313f4a2713aSLionel Sambuc   template<typename T> struct S {
314f4a2713aSLionel Sambuc     template<typename U = void> void g();
315f4a2713aSLionel Sambuc #if __cplusplus < 201103L
316f4a2713aSLionel Sambuc   // expected-error@-2 {{extension}}
317f4a2713aSLionel Sambuc #endif
318f4a2713aSLionel Sambuc     template<typename U> struct X;
319f4a2713aSLionel Sambuc     template<typename U> void h();
320f4a2713aSLionel Sambuc   };
g()321f4a2713aSLionel Sambuc   template<typename T> template<typename U> void S<T>::g() {}
322f4a2713aSLionel Sambuc   template<typename T> template<typename U = void> struct S<T>::X {}; // expected-error {{cannot add a default template arg}}
h()323f4a2713aSLionel Sambuc   template<typename T> template<typename U = void> void S<T>::h() {} // expected-error {{cannot add a default template arg}}
324f4a2713aSLionel Sambuc 
325f4a2713aSLionel Sambuc   template<typename> void friend_h();
326f4a2713aSLionel Sambuc   struct A {
327f4a2713aSLionel Sambuc     // FIXME: This is ill-formed.
328f4a2713aSLionel Sambuc     template<typename=void> struct friend_B;
329f4a2713aSLionel Sambuc     // FIXME: f, h, and i are ill-formed.
330f4a2713aSLionel Sambuc     //  f is ill-formed because it is not a definition.
331f4a2713aSLionel Sambuc     //  h and i are ill-formed because they are not the only declarations of the
332f4a2713aSLionel Sambuc     //  function in the translation unit.
333f4a2713aSLionel Sambuc     template<typename=void> void friend_f();
friend_gdr226::A334f4a2713aSLionel Sambuc     template<typename=void> void friend_g() {}
friend_hdr226::A335f4a2713aSLionel Sambuc     template<typename=void> void friend_h() {}
friend_idr226::A336f4a2713aSLionel Sambuc     template<typename=void> void friend_i() {}
337f4a2713aSLionel Sambuc #if __cplusplus < 201103L
338f4a2713aSLionel Sambuc   // expected-error@-5 {{extension}} expected-error@-4 {{extension}}
339f4a2713aSLionel Sambuc   // expected-error@-4 {{extension}} expected-error@-3 {{extension}}
340f4a2713aSLionel Sambuc #endif
341f4a2713aSLionel Sambuc   };
342f4a2713aSLionel Sambuc   template<typename> void friend_i();
343f4a2713aSLionel Sambuc 
foo(X)344f4a2713aSLionel Sambuc   template<typename=void, typename X> void foo(X) {}
345f4a2713aSLionel Sambuc   template<typename=void, typename X> struct Foo {}; // expected-error {{missing a default argument}} expected-note {{here}}
346f4a2713aSLionel Sambuc #if __cplusplus < 201103L
347f4a2713aSLionel Sambuc   // expected-error@-3 {{extension}}
348f4a2713aSLionel Sambuc #endif
349f4a2713aSLionel Sambuc 
350f4a2713aSLionel Sambuc   template<typename=void, typename X, typename, typename Y> int foo(X, Y);
351f4a2713aSLionel Sambuc   template<typename, typename X, typename=void, typename Y> int foo(X, Y);
352f4a2713aSLionel Sambuc   int x = foo(0, 0);
353f4a2713aSLionel Sambuc #if __cplusplus < 201103L
354f4a2713aSLionel Sambuc   // expected-error@-4 {{extension}}
355f4a2713aSLionel Sambuc   // expected-error@-4 {{extension}}
356f4a2713aSLionel Sambuc #endif
357f4a2713aSLionel Sambuc }
358f4a2713aSLionel Sambuc 
dr227(bool b)359f4a2713aSLionel Sambuc void dr227(bool b) { // dr227: yes
360f4a2713aSLionel Sambuc   if (b)
361f4a2713aSLionel Sambuc     int n;
362f4a2713aSLionel Sambuc   else
363f4a2713aSLionel Sambuc     int n;
364f4a2713aSLionel Sambuc }
365f4a2713aSLionel Sambuc 
366f4a2713aSLionel Sambuc namespace dr228 { // dr228: yes
367f4a2713aSLionel Sambuc   template <class T> struct X {
368f4a2713aSLionel Sambuc     void f();
369f4a2713aSLionel Sambuc   };
370f4a2713aSLionel Sambuc   template <class T> struct Y {
gdr228::Y371f4a2713aSLionel Sambuc     void g(X<T> x) { x.template X<T>::f(); }
372f4a2713aSLionel Sambuc   };
373f4a2713aSLionel Sambuc }
374f4a2713aSLionel Sambuc 
375f4a2713aSLionel Sambuc namespace dr229 { // dr229: yes
376f4a2713aSLionel Sambuc   template<typename T> void f();
f()377f4a2713aSLionel Sambuc   template<typename T> void f<T*>() {} // expected-error {{function template partial specialization}}
f()378f4a2713aSLionel Sambuc   template<> void f<int>() {}
379f4a2713aSLionel Sambuc }
380f4a2713aSLionel Sambuc 
381*0a6a1f1dSLionel Sambuc namespace dr230 { // dr230: yes
382*0a6a1f1dSLionel Sambuc   struct S {
Sdr230::S383*0a6a1f1dSLionel Sambuc     S() { f(); } // expected-warning {{call to pure virtual member function}}
384*0a6a1f1dSLionel Sambuc     virtual void f() = 0; // expected-note {{declared here}}
385*0a6a1f1dSLionel Sambuc   };
386*0a6a1f1dSLionel Sambuc }
387*0a6a1f1dSLionel Sambuc 
388f4a2713aSLionel Sambuc namespace dr231 { // dr231: yes
389f4a2713aSLionel Sambuc   namespace outer {
390f4a2713aSLionel Sambuc     namespace inner {
391f4a2713aSLionel Sambuc       int i; // expected-note {{here}}
392f4a2713aSLionel Sambuc     }
f()393f4a2713aSLionel Sambuc     void f() { using namespace inner; }
394f4a2713aSLionel Sambuc     int j = i; // expected-error {{undeclared identifier 'i'; did you mean 'inner::i'?}}
395f4a2713aSLionel Sambuc   }
396f4a2713aSLionel Sambuc }
397f4a2713aSLionel Sambuc 
398f4a2713aSLionel Sambuc // dr234: na
399f4a2713aSLionel Sambuc // dr235: na
400f4a2713aSLionel Sambuc 
401f4a2713aSLionel Sambuc namespace dr236 { // dr236: yes
402f4a2713aSLionel Sambuc   void *p = int();
403f4a2713aSLionel Sambuc #if __cplusplus < 201103L
404f4a2713aSLionel Sambuc   // expected-warning@-2 {{null pointer}}
405f4a2713aSLionel Sambuc #else
406f4a2713aSLionel Sambuc   // expected-error@-4 {{cannot initialize}}
407f4a2713aSLionel Sambuc #endif
408f4a2713aSLionel Sambuc }
409f4a2713aSLionel Sambuc 
410f4a2713aSLionel Sambuc namespace dr237 { // dr237: dup 470
fdr237::A411f4a2713aSLionel Sambuc   template<typename T> struct A { void f() { T::error; } };
412f4a2713aSLionel Sambuc   template<typename T> struct B : A<T> {};
413f4a2713aSLionel Sambuc   template struct B<int>; // ok
414f4a2713aSLionel Sambuc }
415f4a2713aSLionel Sambuc 
416f4a2713aSLionel Sambuc namespace dr239 { // dr239: yes
417f4a2713aSLionel Sambuc   namespace NS {
418f4a2713aSLionel Sambuc     class T {};
419f4a2713aSLionel Sambuc     void f(T);
420f4a2713aSLionel Sambuc     float &g(T, int);
421f4a2713aSLionel Sambuc   }
422f4a2713aSLionel Sambuc   NS::T parm;
423f4a2713aSLionel Sambuc   int &g(NS::T, float);
main()424f4a2713aSLionel Sambuc   int main() {
425f4a2713aSLionel Sambuc     f(parm);
426f4a2713aSLionel Sambuc     float &r = g(parm, 1);
427f4a2713aSLionel Sambuc     extern int &g(NS::T, float);
428f4a2713aSLionel Sambuc     int &s = g(parm, 1);
429f4a2713aSLionel Sambuc   }
430f4a2713aSLionel Sambuc }
431f4a2713aSLionel Sambuc 
432f4a2713aSLionel Sambuc // dr240: dup 616
433f4a2713aSLionel Sambuc 
434f4a2713aSLionel Sambuc namespace dr241 { // dr241: yes
435f4a2713aSLionel Sambuc   namespace A {
436f4a2713aSLionel Sambuc     struct B {};
437f4a2713aSLionel Sambuc     template <int X> void f(); // expected-note 2{{candidate}}
438f4a2713aSLionel Sambuc     template <int X> void g(B);
439f4a2713aSLionel Sambuc   }
440f4a2713aSLionel Sambuc   namespace C {
441f4a2713aSLionel Sambuc     template <class T> void f(T t); // expected-note 2{{candidate}}
442f4a2713aSLionel Sambuc     template <class T> void g(T t); // expected-note {{candidate}}
443f4a2713aSLionel Sambuc   }
h(A::B b)444f4a2713aSLionel Sambuc   void h(A::B b) {
445f4a2713aSLionel Sambuc     f<3>(b); // expected-error {{undeclared identifier}}
446f4a2713aSLionel Sambuc     g<3>(b); // expected-error {{undeclared identifier}}
447f4a2713aSLionel Sambuc     A::f<3>(b); // expected-error {{no matching}}
448f4a2713aSLionel Sambuc     A::g<3>(b);
449f4a2713aSLionel Sambuc     C::f<3>(b); // expected-error {{no matching}}
450f4a2713aSLionel Sambuc     C::g<3>(b); // expected-error {{no matching}}
451f4a2713aSLionel Sambuc     using C::f;
452f4a2713aSLionel Sambuc     using C::g;
453f4a2713aSLionel Sambuc     f<3>(b); // expected-error {{no matching}}
454f4a2713aSLionel Sambuc     g<3>(b);
455f4a2713aSLionel Sambuc   }
456f4a2713aSLionel Sambuc }
457f4a2713aSLionel Sambuc 
458f4a2713aSLionel Sambuc namespace dr243 { // dr243: yes
459f4a2713aSLionel Sambuc   struct B;
460f4a2713aSLionel Sambuc   struct A {
461f4a2713aSLionel Sambuc     A(B); // expected-note {{candidate}}
462f4a2713aSLionel Sambuc   };
463f4a2713aSLionel Sambuc   struct B {
464f4a2713aSLionel Sambuc     operator A() = delete; // expected-error 0-1{{extension}} expected-note {{candidate}}
465f4a2713aSLionel Sambuc   } b;
466f4a2713aSLionel Sambuc   A a1(b);
467f4a2713aSLionel Sambuc   A a2 = b; // expected-error {{ambiguous}}
468f4a2713aSLionel Sambuc }
469f4a2713aSLionel Sambuc 
470*0a6a1f1dSLionel Sambuc namespace dr244 { // dr244: partial
471f4a2713aSLionel Sambuc   struct B {}; struct D : B {}; // expected-note {{here}}
472f4a2713aSLionel Sambuc 
473f4a2713aSLionel Sambuc   D D_object;
474f4a2713aSLionel Sambuc   typedef B B_alias;
475f4a2713aSLionel Sambuc   B* B_ptr = &D_object;
476f4a2713aSLionel Sambuc 
f()477f4a2713aSLionel Sambuc   void f() {
478f4a2713aSLionel Sambuc     D_object.~B(); // expected-error {{expression does not match the type}}
479f4a2713aSLionel Sambuc     D_object.B::~B();
480f4a2713aSLionel Sambuc     B_ptr->~B();
481f4a2713aSLionel Sambuc     B_ptr->~B_alias();
482f4a2713aSLionel Sambuc     B_ptr->B_alias::~B();
483f4a2713aSLionel Sambuc     // This is valid under DR244.
484*0a6a1f1dSLionel Sambuc     B_ptr->B_alias::~B_alias();
485f4a2713aSLionel Sambuc     B_ptr->dr244::~B(); // expected-error {{refers to a member in namespace}}
486f4a2713aSLionel Sambuc     B_ptr->dr244::~B_alias(); // expected-error {{refers to a member in namespace}}
487f4a2713aSLionel Sambuc   }
488*0a6a1f1dSLionel Sambuc 
489*0a6a1f1dSLionel Sambuc   namespace N {
490*0a6a1f1dSLionel Sambuc     template<typename T> struct E {};
491*0a6a1f1dSLionel Sambuc     typedef E<int> F;
492*0a6a1f1dSLionel Sambuc   }
g(N::F f)493*0a6a1f1dSLionel Sambuc   void g(N::F f) {
494*0a6a1f1dSLionel Sambuc     typedef N::F G;
495*0a6a1f1dSLionel Sambuc     f.~G();
496*0a6a1f1dSLionel Sambuc     f.G::~E();
497*0a6a1f1dSLionel Sambuc     f.G::~F(); // expected-error {{expected the class name after '~' to name a destructor}}
498*0a6a1f1dSLionel Sambuc     f.G::~G();
499*0a6a1f1dSLionel Sambuc     // This is technically ill-formed; E is looked up in 'N::' and names the
500*0a6a1f1dSLionel Sambuc     // class template, not the injected-class-name of the class. But that's
501*0a6a1f1dSLionel Sambuc     // probably a bug in the standard.
502*0a6a1f1dSLionel Sambuc     f.N::F::~E();
503*0a6a1f1dSLionel Sambuc     // This is valid; we look up the second F in the same scope in which we
504*0a6a1f1dSLionel Sambuc     // found the first one, that is, 'N::'.
505*0a6a1f1dSLionel Sambuc     f.N::F::~F(); // FIXME: expected-error {{expected the class name after '~' to name a destructor}}
506*0a6a1f1dSLionel Sambuc     // This is technically ill-formed; G is looked up in 'N::' and is not found;
507*0a6a1f1dSLionel Sambuc     // as above, this is probably a bug in the standard.
508*0a6a1f1dSLionel Sambuc     f.N::F::~G();
509*0a6a1f1dSLionel Sambuc   }
510f4a2713aSLionel Sambuc }
511f4a2713aSLionel Sambuc 
512f4a2713aSLionel Sambuc namespace dr245 { // dr245: yes
513f4a2713aSLionel Sambuc   struct S {
514f4a2713aSLionel Sambuc     enum E {}; // expected-note {{here}}
515f4a2713aSLionel Sambuc     class E *p; // expected-error {{does not match previous declaration}}
516f4a2713aSLionel Sambuc   };
517f4a2713aSLionel Sambuc }
518f4a2713aSLionel Sambuc 
519f4a2713aSLionel Sambuc namespace dr246 { // dr246: yes
520f4a2713aSLionel Sambuc   struct S {
Sdr246::S521f4a2713aSLionel Sambuc     S() try { // expected-note {{try block}}
522f4a2713aSLionel Sambuc       throw 0;
523f4a2713aSLionel Sambuc X: ;
524f4a2713aSLionel Sambuc     } catch (int) {
525*0a6a1f1dSLionel Sambuc       goto X; // expected-error {{cannot jump}}
526f4a2713aSLionel Sambuc     }
527f4a2713aSLionel Sambuc   };
528f4a2713aSLionel Sambuc }
529f4a2713aSLionel Sambuc 
530f4a2713aSLionel Sambuc namespace dr247 { // dr247: yes
531f4a2713aSLionel Sambuc   struct A {};
532f4a2713aSLionel Sambuc   struct B : A {
533f4a2713aSLionel Sambuc     void f();
534f4a2713aSLionel Sambuc     void f(int);
535f4a2713aSLionel Sambuc   };
536f4a2713aSLionel Sambuc   void (A::*f)() = (void (A::*)())&B::f;
537f4a2713aSLionel Sambuc 
538f4a2713aSLionel Sambuc   struct C {
539f4a2713aSLionel Sambuc     void f();
540f4a2713aSLionel Sambuc     void f(int);
541f4a2713aSLionel Sambuc   };
542f4a2713aSLionel Sambuc   struct D : C {};
543f4a2713aSLionel Sambuc   void (C::*g)() = &D::f;
544f4a2713aSLionel Sambuc   void (D::*h)() = &D::f;
545f4a2713aSLionel Sambuc 
546f4a2713aSLionel Sambuc   struct E {
547f4a2713aSLionel Sambuc     void f();
548f4a2713aSLionel Sambuc   };
549f4a2713aSLionel Sambuc   struct F : E {
550f4a2713aSLionel Sambuc     using E::f;
551f4a2713aSLionel Sambuc     void f(int);
552f4a2713aSLionel Sambuc   };
553f4a2713aSLionel Sambuc   void (F::*i)() = &F::f;
554f4a2713aSLionel Sambuc }
555f4a2713aSLionel Sambuc 
556f4a2713aSLionel Sambuc namespace dr248 { // dr248: yes c++11
557f4a2713aSLionel Sambuc   // FIXME: Should this also apply to c++98 mode? This was a DR against C++98.
558f4a2713aSLionel Sambuc   int \u040d\u040e = 0;
559f4a2713aSLionel Sambuc #if __cplusplus < 201103L
560f4a2713aSLionel Sambuc   // FIXME: expected-error@-2 {{expected ';'}}
561f4a2713aSLionel Sambuc #endif
562f4a2713aSLionel Sambuc }
563f4a2713aSLionel Sambuc 
564f4a2713aSLionel Sambuc namespace dr249 { // dr249: yes
565f4a2713aSLionel Sambuc   template<typename T> struct X { void f(); };
f()566f4a2713aSLionel Sambuc   template<typename T> void X<T>::f() {}
567f4a2713aSLionel Sambuc }
568f4a2713aSLionel Sambuc 
569f4a2713aSLionel Sambuc namespace dr250 { // dr250: yes
570f4a2713aSLionel Sambuc   typedef void (*FPtr)(double x[]);
571f4a2713aSLionel Sambuc 
572f4a2713aSLionel Sambuc   template<int I> void f(double x[]);
573f4a2713aSLionel Sambuc   FPtr fp = &f<3>;
574f4a2713aSLionel Sambuc 
575f4a2713aSLionel Sambuc   template<int I = 3> void g(double x[]); // expected-error 0-1{{extension}}
576f4a2713aSLionel Sambuc   FPtr gp = &g<>;
577f4a2713aSLionel Sambuc }
578f4a2713aSLionel Sambuc 
579f4a2713aSLionel Sambuc namespace dr252 { // dr252: yes
580f4a2713aSLionel Sambuc   struct A {
581f4a2713aSLionel Sambuc     void operator delete(void*); // expected-note {{found}}
582f4a2713aSLionel Sambuc   };
583f4a2713aSLionel Sambuc   struct B {
584f4a2713aSLionel Sambuc     void operator delete(void*); // expected-note {{found}}
585f4a2713aSLionel Sambuc   };
586f4a2713aSLionel Sambuc   struct C : A, B {
587f4a2713aSLionel Sambuc     virtual ~C();
588f4a2713aSLionel Sambuc   };
~C()589f4a2713aSLionel Sambuc   C::~C() {} // expected-error {{'operator delete' found in multiple base classes}}
590f4a2713aSLionel Sambuc 
591f4a2713aSLionel Sambuc   struct D {
592f4a2713aSLionel Sambuc     void operator delete(void*, int); // expected-note {{here}}
593f4a2713aSLionel Sambuc     virtual ~D();
594f4a2713aSLionel Sambuc   };
~D()595f4a2713aSLionel Sambuc   D::~D() {} // expected-error {{no suitable member 'operator delete'}}
596f4a2713aSLionel Sambuc 
597f4a2713aSLionel Sambuc   struct E {
598f4a2713aSLionel Sambuc     void operator delete(void*, int);
599*0a6a1f1dSLionel Sambuc     void operator delete(void*) = delete; // expected-error 0-1{{extension}} expected-note 1-2 {{here}}
600*0a6a1f1dSLionel Sambuc     virtual ~E(); // expected-error 0-1 {{attempt to use a deleted function}}
601f4a2713aSLionel Sambuc   };
~E()602*0a6a1f1dSLionel Sambuc   E::~E() {} // expected-error {{attempt to use a deleted function}}
603f4a2713aSLionel Sambuc 
604f4a2713aSLionel Sambuc   struct F {
605f4a2713aSLionel Sambuc     // If both functions are available, the first one is a placement delete.
606*0a6a1f1dSLionel Sambuc     void operator delete(void*, size_t);
607f4a2713aSLionel Sambuc     void operator delete(void*) = delete; // expected-error 0-1{{extension}} expected-note {{here}}
608f4a2713aSLionel Sambuc     virtual ~F();
609f4a2713aSLionel Sambuc   };
~F()610*0a6a1f1dSLionel Sambuc   F::~F() {} // expected-error {{attempt to use a deleted function}}
611f4a2713aSLionel Sambuc 
612f4a2713aSLionel Sambuc   struct G {
613*0a6a1f1dSLionel Sambuc     void operator delete(void*, size_t);
614f4a2713aSLionel Sambuc     virtual ~G();
615f4a2713aSLionel Sambuc   };
~G()616f4a2713aSLionel Sambuc   G::~G() {}
617f4a2713aSLionel Sambuc }
618f4a2713aSLionel Sambuc 
619f4a2713aSLionel Sambuc namespace dr254 { // dr254: yes
620f4a2713aSLionel Sambuc   template<typename T> struct A {
621f4a2713aSLionel Sambuc     typedef typename T::type type; // ok even if this is a typedef-name, because
622f4a2713aSLionel Sambuc                                    // it's not an elaborated-type-specifier
623f4a2713aSLionel Sambuc     typedef struct T::type foo; // expected-error {{elaborated type refers to a typedef}}
624f4a2713aSLionel Sambuc   };
625f4a2713aSLionel Sambuc   struct B { struct type {}; };
626f4a2713aSLionel Sambuc   struct C { typedef struct {} type; }; // expected-note {{here}}
627f4a2713aSLionel Sambuc   A<B>::type n;
628f4a2713aSLionel Sambuc   A<C>::type n; // expected-note {{instantiation of}}
629f4a2713aSLionel Sambuc }
630f4a2713aSLionel Sambuc 
631f4a2713aSLionel Sambuc // dr256: dup 624
632f4a2713aSLionel Sambuc 
633f4a2713aSLionel Sambuc namespace dr257 { // dr257: yes
634f4a2713aSLionel Sambuc   struct A { A(int); }; // expected-note {{here}}
635f4a2713aSLionel Sambuc   struct B : virtual A {
Bdr257::B636f4a2713aSLionel Sambuc     B() {}
637f4a2713aSLionel Sambuc     virtual void f() = 0;
638f4a2713aSLionel Sambuc   };
639f4a2713aSLionel Sambuc   struct C : B {
Cdr257::C640f4a2713aSLionel Sambuc     C() {}
641f4a2713aSLionel Sambuc   };
642f4a2713aSLionel Sambuc   struct D : B {
Ddr257::D643f4a2713aSLionel Sambuc     D() {} // expected-error {{must explicitly initialize the base class 'dr257::A'}}
644f4a2713aSLionel Sambuc     void f();
645f4a2713aSLionel Sambuc   };
646f4a2713aSLionel Sambuc }
647f4a2713aSLionel Sambuc 
648f4a2713aSLionel Sambuc namespace dr258 { // dr258: yes
649f4a2713aSLionel Sambuc   struct A {
650f4a2713aSLionel Sambuc     void f(const int);
651f4a2713aSLionel Sambuc     template<typename> void g(int);
652f4a2713aSLionel Sambuc     float &h() const;
653f4a2713aSLionel Sambuc   };
654f4a2713aSLionel Sambuc   struct B : A {
655f4a2713aSLionel Sambuc     using A::f;
656f4a2713aSLionel Sambuc     using A::g;
657f4a2713aSLionel Sambuc     using A::h;
658f4a2713aSLionel Sambuc     int &f(int);
659f4a2713aSLionel Sambuc     template<int> int &g(int); // expected-note {{candidate}}
660f4a2713aSLionel Sambuc     int &h();
661f4a2713aSLionel Sambuc   } b;
662f4a2713aSLionel Sambuc   int &w = b.f(0);
663f4a2713aSLionel Sambuc   int &x = b.g<int>(0); // expected-error {{no match}}
664f4a2713aSLionel Sambuc   int &y = b.h();
665f4a2713aSLionel Sambuc   float &z = const_cast<const B&>(b).h();
666f4a2713aSLionel Sambuc 
667f4a2713aSLionel Sambuc   struct C {
668f4a2713aSLionel Sambuc     virtual void f(const int) = 0;
669f4a2713aSLionel Sambuc   };
670f4a2713aSLionel Sambuc   struct D : C {
671f4a2713aSLionel Sambuc     void f(int);
672f4a2713aSLionel Sambuc   } d;
673f4a2713aSLionel Sambuc 
674f4a2713aSLionel Sambuc   struct E {
675f4a2713aSLionel Sambuc     virtual void f() = 0; // expected-note {{unimplemented}}
676f4a2713aSLionel Sambuc   };
677f4a2713aSLionel Sambuc   struct F : E {
fdr258::F678f4a2713aSLionel Sambuc     void f() const {}
679f4a2713aSLionel Sambuc   } f; // expected-error {{abstract}}
680f4a2713aSLionel Sambuc }
681f4a2713aSLionel Sambuc 
682f4a2713aSLionel Sambuc namespace dr259 { // dr259: yes c++11
683f4a2713aSLionel Sambuc   template<typename T> struct A {};
684f4a2713aSLionel Sambuc   template struct A<int>; // expected-note {{previous}}
685f4a2713aSLionel Sambuc   template struct A<int>; // expected-error {{duplicate explicit instantiation}}
686f4a2713aSLionel Sambuc 
687f4a2713aSLionel Sambuc   // FIXME: We only apply this DR in C++11 mode.
688f4a2713aSLionel Sambuc   template<> struct A<float>;
689f4a2713aSLionel Sambuc   template struct A<float>;
690f4a2713aSLionel Sambuc #if __cplusplus < 201103L
691f4a2713aSLionel Sambuc   // expected-error@-2 {{extension}} expected-note@-3 {{here}}
692f4a2713aSLionel Sambuc #endif
693f4a2713aSLionel Sambuc 
694f4a2713aSLionel Sambuc   template struct A<char>; // expected-note {{here}}
695f4a2713aSLionel Sambuc   template<> struct A<char>; // expected-error {{explicit specialization of 'dr259::A<char>' after instantiation}}
696f4a2713aSLionel Sambuc 
697f4a2713aSLionel Sambuc   template<> struct A<double>;
698f4a2713aSLionel Sambuc   template<> struct A<double>;
699f4a2713aSLionel Sambuc   template<> struct A<double> {}; // expected-note {{here}}
700f4a2713aSLionel Sambuc   template<> struct A<double> {}; // expected-error {{redefinition}}
701f4a2713aSLionel Sambuc 
702f4a2713aSLionel Sambuc   template<typename T> struct B; // expected-note {{here}}
703f4a2713aSLionel Sambuc   template struct B<int>; // expected-error {{undefined}}
704f4a2713aSLionel Sambuc 
705f4a2713aSLionel Sambuc   template<> struct B<float>;
706f4a2713aSLionel Sambuc   template struct B<float>;
707f4a2713aSLionel Sambuc #if __cplusplus < 201103L
708f4a2713aSLionel Sambuc   // expected-error@-2 {{extension}} expected-note@-3 {{here}}
709f4a2713aSLionel Sambuc #endif
710f4a2713aSLionel Sambuc }
711f4a2713aSLionel Sambuc 
712*0a6a1f1dSLionel Sambuc // FIXME: When dr260 is resolved, also add tests for DR507.
713*0a6a1f1dSLionel Sambuc 
714f4a2713aSLionel Sambuc namespace dr261 { // dr261: no
715f4a2713aSLionel Sambuc #pragma clang diagnostic push
716f4a2713aSLionel Sambuc #pragma clang diagnostic warning "-Wused-but-marked-unused"
717f4a2713aSLionel Sambuc 
718f4a2713aSLionel Sambuc   // FIXME: This is ill-formed, with a diagnostic required, because operator new
719f4a2713aSLionel Sambuc   // and operator delete are inline and odr-used, but not defined in this
720f4a2713aSLionel Sambuc   // translation unit.
721f4a2713aSLionel Sambuc   // We're also missing the -Wused-but-marked-unused diagnostic here.
722f4a2713aSLionel Sambuc   struct A {
723*0a6a1f1dSLionel Sambuc     inline void *operator new(size_t) __attribute__((unused));
724f4a2713aSLionel Sambuc     inline void operator delete(void*) __attribute__((unused));
Adr261::A725f4a2713aSLionel Sambuc     A() {}
726f4a2713aSLionel Sambuc   };
727f4a2713aSLionel Sambuc 
728f4a2713aSLionel Sambuc   // FIXME: These are ill-formed, with a required diagnostic, for the same
729f4a2713aSLionel Sambuc   // reason.
730f4a2713aSLionel Sambuc   struct B {
731f4a2713aSLionel Sambuc     inline void operator delete(void*) __attribute__((unused));
~Bdr261::B732f4a2713aSLionel Sambuc     ~B() {}
733f4a2713aSLionel Sambuc   };
734f4a2713aSLionel Sambuc   struct C {
735f4a2713aSLionel Sambuc     inline void operator delete(void*) __attribute__((unused));
~Cdr261::C736f4a2713aSLionel Sambuc     virtual ~C() {}
737f4a2713aSLionel Sambuc   };
738f4a2713aSLionel Sambuc 
739f4a2713aSLionel Sambuc   struct D {
740f4a2713aSLionel Sambuc     inline void operator delete(void*) __attribute__((unused));
741f4a2713aSLionel Sambuc   };
h()742f4a2713aSLionel Sambuc   void h() { C::operator delete(0); } // expected-warning {{marked unused but was used}}
743f4a2713aSLionel Sambuc 
744f4a2713aSLionel Sambuc #pragma clang diagnostic pop
745f4a2713aSLionel Sambuc }
746f4a2713aSLionel Sambuc 
747f4a2713aSLionel Sambuc namespace dr262 { // dr262: yes
748f4a2713aSLionel Sambuc   int f(int = 0, ...);
749f4a2713aSLionel Sambuc   int k = f();
750f4a2713aSLionel Sambuc   int l = f(0);
751f4a2713aSLionel Sambuc   int m = f(0, 0);
752f4a2713aSLionel Sambuc }
753f4a2713aSLionel Sambuc 
754f4a2713aSLionel Sambuc namespace dr263 { // dr263: yes
755f4a2713aSLionel Sambuc   struct X {};
756f4a2713aSLionel Sambuc   struct Y {
757f4a2713aSLionel Sambuc #if __cplusplus < 201103L
758f4a2713aSLionel Sambuc     friend X::X() throw();
759f4a2713aSLionel Sambuc     friend X::~X() throw();
760f4a2713aSLionel Sambuc #else
761f4a2713aSLionel Sambuc     friend constexpr X::X() noexcept;
762f4a2713aSLionel Sambuc     friend X::~X();
763f4a2713aSLionel Sambuc #endif
764f4a2713aSLionel Sambuc     Y::Y(); // expected-error {{extra qualification}}
765f4a2713aSLionel Sambuc     Y::~Y(); // expected-error {{extra qualification}}
766f4a2713aSLionel Sambuc   };
767f4a2713aSLionel Sambuc }
768f4a2713aSLionel Sambuc 
769f4a2713aSLionel Sambuc // dr265: dup 353
770f4a2713aSLionel Sambuc // dr266: na
771f4a2713aSLionel Sambuc // dr269: na
772f4a2713aSLionel Sambuc // dr270: na
773*0a6a1f1dSLionel Sambuc 
774*0a6a1f1dSLionel Sambuc namespace dr272 { // dr272: yes
775*0a6a1f1dSLionel Sambuc   struct X {
fdr272::X776*0a6a1f1dSLionel Sambuc     void f() {
777*0a6a1f1dSLionel Sambuc       this->~X();
778*0a6a1f1dSLionel Sambuc       X::~X();
779*0a6a1f1dSLionel Sambuc       ~X(); // expected-error {{unary expression}}
780*0a6a1f1dSLionel Sambuc     }
781*0a6a1f1dSLionel Sambuc   };
782*0a6a1f1dSLionel Sambuc }
783*0a6a1f1dSLionel Sambuc 
784*0a6a1f1dSLionel Sambuc #include <stdarg.h>
785*0a6a1f1dSLionel Sambuc #include <stddef.h>
786*0a6a1f1dSLionel Sambuc namespace dr273 { // dr273: yes
787*0a6a1f1dSLionel Sambuc   struct A {
788*0a6a1f1dSLionel Sambuc     int n;
789*0a6a1f1dSLionel Sambuc   };
790*0a6a1f1dSLionel Sambuc   void operator&(A);
f(A a,...)791*0a6a1f1dSLionel Sambuc   void f(A a, ...) {
792*0a6a1f1dSLionel Sambuc     offsetof(A, n);
793*0a6a1f1dSLionel Sambuc     va_list val;
794*0a6a1f1dSLionel Sambuc     va_start(val, a);
795*0a6a1f1dSLionel Sambuc     va_end(val);
796*0a6a1f1dSLionel Sambuc   }
797*0a6a1f1dSLionel Sambuc }
798*0a6a1f1dSLionel Sambuc 
799*0a6a1f1dSLionel Sambuc // dr274: na
800*0a6a1f1dSLionel Sambuc 
801*0a6a1f1dSLionel Sambuc namespace dr275 { // dr275: no
802*0a6a1f1dSLionel Sambuc   namespace N {
f(T)803*0a6a1f1dSLionel Sambuc     template <class T> void f(T) {} // expected-note 1-4{{here}}
g(T)804*0a6a1f1dSLionel Sambuc     template <class T> void g(T) {} // expected-note {{candidate}}
805*0a6a1f1dSLionel Sambuc     template <> void f(int);
806*0a6a1f1dSLionel Sambuc     template <> void f(char);
807*0a6a1f1dSLionel Sambuc     template <> void f(double);
808*0a6a1f1dSLionel Sambuc     template <> void g(char);
809*0a6a1f1dSLionel Sambuc   }
810*0a6a1f1dSLionel Sambuc 
811*0a6a1f1dSLionel Sambuc   using namespace N;
812*0a6a1f1dSLionel Sambuc 
813*0a6a1f1dSLionel Sambuc   namespace M {
f(char)814*0a6a1f1dSLionel Sambuc     template <> void N::f(char) {} // expected-error {{'M' does not enclose namespace 'N'}}
g(T)815*0a6a1f1dSLionel Sambuc     template <class T> void g(T) {}
g(char)816*0a6a1f1dSLionel Sambuc     template <> void g(char) {}
817*0a6a1f1dSLionel Sambuc     template void f(long);
818*0a6a1f1dSLionel Sambuc #if __cplusplus >= 201103L
819*0a6a1f1dSLionel Sambuc     // FIXME: this should be rejected in c++98 too
820*0a6a1f1dSLionel Sambuc     // expected-error@-3 {{must occur in namespace 'N'}}
821*0a6a1f1dSLionel Sambuc #endif
822*0a6a1f1dSLionel Sambuc     template void N::f(unsigned long);
823*0a6a1f1dSLionel Sambuc #if __cplusplus >= 201103L
824*0a6a1f1dSLionel Sambuc     // FIXME: this should be rejected in c++98 too
825*0a6a1f1dSLionel Sambuc     // expected-error@-3 {{not in a namespace enclosing 'N'}}
826*0a6a1f1dSLionel Sambuc #endif
827*0a6a1f1dSLionel Sambuc     template void h(long); // expected-error {{does not refer to a function template}}
f(double)828*0a6a1f1dSLionel Sambuc     template <> void f(double) {} // expected-error {{no function template matches}}
829*0a6a1f1dSLionel Sambuc   }
830*0a6a1f1dSLionel Sambuc 
g(T)831*0a6a1f1dSLionel Sambuc   template <class T> void g(T) {} // expected-note {{candidate}}
832*0a6a1f1dSLionel Sambuc 
f(char)833*0a6a1f1dSLionel Sambuc   template <> void N::f(char) {}
f(int)834*0a6a1f1dSLionel Sambuc   template <> void f(int) {} // expected-error {{no function template matches}}
835*0a6a1f1dSLionel Sambuc 
836*0a6a1f1dSLionel Sambuc   template void f(short);
837*0a6a1f1dSLionel Sambuc #if __cplusplus >= 201103L
838*0a6a1f1dSLionel Sambuc   // FIXME: this should be rejected in c++98 too
839*0a6a1f1dSLionel Sambuc   // expected-error@-3 {{must occur in namespace 'N'}}
840*0a6a1f1dSLionel Sambuc #endif
841*0a6a1f1dSLionel Sambuc   template void N::f(unsigned short);
842*0a6a1f1dSLionel Sambuc 
843*0a6a1f1dSLionel Sambuc   // FIXME: this should probably be valid. the wording from the issue
844*0a6a1f1dSLionel Sambuc   // doesn't clarify this, but it follows from the usual rules.
845*0a6a1f1dSLionel Sambuc   template void g(int); // expected-error {{ambiguous}}
846*0a6a1f1dSLionel Sambuc 
847*0a6a1f1dSLionel Sambuc   // FIXME: likewise, this should also be valid.
f(T)848*0a6a1f1dSLionel Sambuc   template<typename T> void f(T) {} // expected-note {{candidate}}
849*0a6a1f1dSLionel Sambuc   template void f(short); // expected-error {{ambiguous}}
850*0a6a1f1dSLionel Sambuc }
851*0a6a1f1dSLionel Sambuc 
852*0a6a1f1dSLionel Sambuc // dr276: na
853*0a6a1f1dSLionel Sambuc 
854*0a6a1f1dSLionel Sambuc namespace dr277 { // dr277: yes
855*0a6a1f1dSLionel Sambuc   typedef int *intp;
856*0a6a1f1dSLionel Sambuc   int *p = intp();
857*0a6a1f1dSLionel Sambuc   int a[fold(intp() ? -1 : 1)];
858*0a6a1f1dSLionel Sambuc }
859*0a6a1f1dSLionel Sambuc 
860*0a6a1f1dSLionel Sambuc namespace dr280 { // dr280: yes
861*0a6a1f1dSLionel Sambuc   typedef void f0();
862*0a6a1f1dSLionel Sambuc   typedef void f1(int);
863*0a6a1f1dSLionel Sambuc   typedef void f2(int, int);
864*0a6a1f1dSLionel Sambuc   typedef void f3(int, int, int);
865*0a6a1f1dSLionel Sambuc   struct A {
866*0a6a1f1dSLionel Sambuc     operator f1*(); // expected-note {{here}} expected-note {{candidate}}
867*0a6a1f1dSLionel Sambuc     operator f2*();
868*0a6a1f1dSLionel Sambuc   };
869*0a6a1f1dSLionel Sambuc   struct B {
870*0a6a1f1dSLionel Sambuc     operator f0*(); // expected-note {{candidate}}
871*0a6a1f1dSLionel Sambuc   private:
872*0a6a1f1dSLionel Sambuc     operator f3*(); // expected-note {{here}} expected-note {{candidate}}
873*0a6a1f1dSLionel Sambuc   };
874*0a6a1f1dSLionel Sambuc   struct C {
875*0a6a1f1dSLionel Sambuc     operator f0*(); // expected-note {{candidate}}
876*0a6a1f1dSLionel Sambuc     operator f1*(); // expected-note {{candidate}}
877*0a6a1f1dSLionel Sambuc     operator f2*(); // expected-note {{candidate}}
878*0a6a1f1dSLionel Sambuc     operator f3*(); // expected-note {{candidate}}
879*0a6a1f1dSLionel Sambuc   };
880*0a6a1f1dSLionel Sambuc   struct D : private A, B { // expected-note 2{{here}}
881*0a6a1f1dSLionel Sambuc     operator f2*(); // expected-note {{candidate}}
882*0a6a1f1dSLionel Sambuc   } d;
883*0a6a1f1dSLionel Sambuc   struct E : C, D {} e;
g()884*0a6a1f1dSLionel Sambuc   void g() {
885*0a6a1f1dSLionel Sambuc     d(); // ok, public
886*0a6a1f1dSLionel Sambuc     d(0); // expected-error {{private member of 'dr280::A'}} expected-error {{private base class 'dr280::A'}}
887*0a6a1f1dSLionel Sambuc     d(0, 0); // ok, suppressed by member in D
888*0a6a1f1dSLionel Sambuc     d(0, 0, 0); // expected-error {{private member of 'dr280::B'}}
889*0a6a1f1dSLionel Sambuc     e(); // expected-error {{ambiguous}}
890*0a6a1f1dSLionel Sambuc     e(0); // expected-error {{ambiguous}}
891*0a6a1f1dSLionel Sambuc     e(0, 0); // expected-error {{ambiguous}}
892*0a6a1f1dSLionel Sambuc     e(0, 0, 0); // expected-error {{ambiguous}}
893*0a6a1f1dSLionel Sambuc   }
894*0a6a1f1dSLionel Sambuc }
895*0a6a1f1dSLionel Sambuc 
896*0a6a1f1dSLionel Sambuc namespace dr281 { // dr281: no
897*0a6a1f1dSLionel Sambuc   void a();
898*0a6a1f1dSLionel Sambuc   inline void b();
899*0a6a1f1dSLionel Sambuc 
900*0a6a1f1dSLionel Sambuc   void d();
901*0a6a1f1dSLionel Sambuc   inline void e();
902*0a6a1f1dSLionel Sambuc 
903*0a6a1f1dSLionel Sambuc   struct S {
904*0a6a1f1dSLionel Sambuc     friend inline void a(); // FIXME: ill-formed
905*0a6a1f1dSLionel Sambuc     friend inline void b();
906*0a6a1f1dSLionel Sambuc     friend inline void c(); // FIXME: ill-formed
d()907*0a6a1f1dSLionel Sambuc     friend inline void d() {}
e()908*0a6a1f1dSLionel Sambuc     friend inline void e() {}
f()909*0a6a1f1dSLionel Sambuc     friend inline void f() {}
910*0a6a1f1dSLionel Sambuc   };
911*0a6a1f1dSLionel Sambuc }
912*0a6a1f1dSLionel Sambuc 
913*0a6a1f1dSLionel Sambuc namespace dr283 { // dr283: yes
914*0a6a1f1dSLionel Sambuc   template<typename T> // expected-note 2{{here}}
915*0a6a1f1dSLionel Sambuc   struct S {
916*0a6a1f1dSLionel Sambuc     friend class T; // expected-error {{shadows}}
917*0a6a1f1dSLionel Sambuc     class T; // expected-error {{shadows}}
918*0a6a1f1dSLionel Sambuc   };
919*0a6a1f1dSLionel Sambuc }
920*0a6a1f1dSLionel Sambuc 
921*0a6a1f1dSLionel Sambuc namespace dr284 { // dr284: no
922*0a6a1f1dSLionel Sambuc   namespace A {
923*0a6a1f1dSLionel Sambuc     struct X;
924*0a6a1f1dSLionel Sambuc     enum Y {};
925*0a6a1f1dSLionel Sambuc     class Z {};
926*0a6a1f1dSLionel Sambuc   }
927*0a6a1f1dSLionel Sambuc   namespace B {
928*0a6a1f1dSLionel Sambuc     struct W;
929*0a6a1f1dSLionel Sambuc     using A::X;
930*0a6a1f1dSLionel Sambuc     using A::Y;
931*0a6a1f1dSLionel Sambuc     using A::Z;
932*0a6a1f1dSLionel Sambuc   }
933*0a6a1f1dSLionel Sambuc   struct B::V {}; // expected-error {{no struct named 'V'}}
934*0a6a1f1dSLionel Sambuc   struct B::W {};
935*0a6a1f1dSLionel Sambuc   struct B::X {}; // FIXME: ill-formed
936*0a6a1f1dSLionel Sambuc   enum B::Y e; // ok per dr417
937*0a6a1f1dSLionel Sambuc   class B::Z z; // ok per dr417
938*0a6a1f1dSLionel Sambuc 
939*0a6a1f1dSLionel Sambuc   struct C {
940*0a6a1f1dSLionel Sambuc     struct X;
941*0a6a1f1dSLionel Sambuc     enum Y {};
942*0a6a1f1dSLionel Sambuc     class Z {};
943*0a6a1f1dSLionel Sambuc   };
944*0a6a1f1dSLionel Sambuc   struct D : C {
945*0a6a1f1dSLionel Sambuc     struct W;
946*0a6a1f1dSLionel Sambuc     using C::X;
947*0a6a1f1dSLionel Sambuc     using C::Y;
948*0a6a1f1dSLionel Sambuc     using C::Z;
949*0a6a1f1dSLionel Sambuc   };
950*0a6a1f1dSLionel Sambuc   struct D::V {}; // expected-error {{no struct named 'V'}}
951*0a6a1f1dSLionel Sambuc   struct D::W {};
952*0a6a1f1dSLionel Sambuc   struct D::X {}; // FIXME: ill-formed
953*0a6a1f1dSLionel Sambuc   enum D::Y e2; // ok per dr417
954*0a6a1f1dSLionel Sambuc   class D::Z z2; // ok per dr417
955*0a6a1f1dSLionel Sambuc }
956*0a6a1f1dSLionel Sambuc 
957*0a6a1f1dSLionel Sambuc namespace dr285 { // dr285: yes
958*0a6a1f1dSLionel Sambuc   template<typename T> void f(T, int); // expected-note {{match}}
959*0a6a1f1dSLionel Sambuc   template<typename T> void f(int, T); // expected-note {{match}}
f(int,int)960*0a6a1f1dSLionel Sambuc   template<> void f<int>(int, int) {} // expected-error {{ambiguous}}
961*0a6a1f1dSLionel Sambuc }
962*0a6a1f1dSLionel Sambuc 
963*0a6a1f1dSLionel Sambuc namespace dr286 { // dr286: yes
964*0a6a1f1dSLionel Sambuc   template<class T> struct A {
965*0a6a1f1dSLionel Sambuc     class C {
966*0a6a1f1dSLionel Sambuc       template<class T2> struct B {}; // expected-note {{here}}
967*0a6a1f1dSLionel Sambuc     };
968*0a6a1f1dSLionel Sambuc   };
969*0a6a1f1dSLionel Sambuc 
970*0a6a1f1dSLionel Sambuc   template<class T>
971*0a6a1f1dSLionel Sambuc   template<class T2>
972*0a6a1f1dSLionel Sambuc   struct A<T>::C::B<T2*> { };
973*0a6a1f1dSLionel Sambuc 
974*0a6a1f1dSLionel Sambuc   A<short>::C::B<int*> absip; // expected-error {{private}}
975*0a6a1f1dSLionel Sambuc }
976*0a6a1f1dSLionel Sambuc 
977*0a6a1f1dSLionel Sambuc // dr288: na
978*0a6a1f1dSLionel Sambuc 
979*0a6a1f1dSLionel Sambuc namespace dr289 { // dr289: yes
980*0a6a1f1dSLionel Sambuc   struct A; // expected-note {{forward}}
981*0a6a1f1dSLionel Sambuc   struct B : A {}; // expected-error {{incomplete}}
982*0a6a1f1dSLionel Sambuc 
983*0a6a1f1dSLionel Sambuc   template<typename T> struct C { typename T::error error; }; // expected-error {{cannot be used prior to '::'}}
984*0a6a1f1dSLionel Sambuc   struct D : C<int> {}; // expected-note {{instantiation}}
985*0a6a1f1dSLionel Sambuc }
986*0a6a1f1dSLionel Sambuc 
987*0a6a1f1dSLionel Sambuc // dr290: na
988*0a6a1f1dSLionel Sambuc // dr291: dup 391
989*0a6a1f1dSLionel Sambuc // dr292 FIXME: write a codegen test
990*0a6a1f1dSLionel Sambuc 
991*0a6a1f1dSLionel Sambuc namespace dr294 { // dr294: no
992*0a6a1f1dSLionel Sambuc   void f() throw(int);
main()993*0a6a1f1dSLionel Sambuc   int main() {
994*0a6a1f1dSLionel Sambuc     (void)static_cast<void (*)() throw()>(f); // FIXME: ill-formed
995*0a6a1f1dSLionel Sambuc     (void)static_cast<void (*)() throw(int)>(f); // FIXME: ill-formed
996*0a6a1f1dSLionel Sambuc 
997*0a6a1f1dSLionel Sambuc     void (*p)() throw() = f; // expected-error {{not superset}}
998*0a6a1f1dSLionel Sambuc     void (*q)() throw(int) = f;
999*0a6a1f1dSLionel Sambuc   }
1000*0a6a1f1dSLionel Sambuc }
1001*0a6a1f1dSLionel Sambuc 
1002*0a6a1f1dSLionel Sambuc namespace dr295 { // dr295: no
1003*0a6a1f1dSLionel Sambuc   typedef int f();
1004*0a6a1f1dSLionel Sambuc   // FIXME: This warning is incorrect.
1005*0a6a1f1dSLionel Sambuc   const f g; // expected-warning {{unspecified behavior}}
1006*0a6a1f1dSLionel Sambuc   const f &r = g; // expected-warning {{unspecified behavior}}
1007*0a6a1f1dSLionel Sambuc   template<typename T> struct X {
1008*0a6a1f1dSLionel Sambuc     const T &f;
1009*0a6a1f1dSLionel Sambuc   };
1010*0a6a1f1dSLionel Sambuc   X<f> x = {g}; // FIXME: expected-error {{drops qualifiers}}
1011*0a6a1f1dSLionel Sambuc }
1012*0a6a1f1dSLionel Sambuc 
1013*0a6a1f1dSLionel Sambuc namespace dr296 { // dr296: yes
1014*0a6a1f1dSLionel Sambuc   struct A {
operator intdr296::A1015*0a6a1f1dSLionel Sambuc     static operator int() { return 0; } // expected-error {{static}}
1016*0a6a1f1dSLionel Sambuc   };
1017*0a6a1f1dSLionel Sambuc }
1018*0a6a1f1dSLionel Sambuc 
1019*0a6a1f1dSLionel Sambuc namespace dr298 { // dr298: yes
1020*0a6a1f1dSLionel Sambuc   struct A {
1021*0a6a1f1dSLionel Sambuc     typedef int type;
1022*0a6a1f1dSLionel Sambuc     A();
1023*0a6a1f1dSLionel Sambuc     ~A();
1024*0a6a1f1dSLionel Sambuc   };
1025*0a6a1f1dSLionel Sambuc   typedef A B; // expected-note {{here}}
1026*0a6a1f1dSLionel Sambuc   typedef const A C; // expected-note {{here}}
1027*0a6a1f1dSLionel Sambuc 
1028*0a6a1f1dSLionel Sambuc   A::type i1;
1029*0a6a1f1dSLionel Sambuc   B::type i2;
1030*0a6a1f1dSLionel Sambuc   C::type i3;
1031*0a6a1f1dSLionel Sambuc 
1032*0a6a1f1dSLionel Sambuc   struct A a;
1033*0a6a1f1dSLionel Sambuc   struct B b; // expected-error {{refers to a typedef}}
1034*0a6a1f1dSLionel Sambuc   struct C c; // expected-error {{refers to a typedef}}
1035*0a6a1f1dSLionel Sambuc 
B()1036*0a6a1f1dSLionel Sambuc   B::B() {} // expected-error {{requires a type specifier}}
A()1037*0a6a1f1dSLionel Sambuc   B::A() {} // ok
~C()1038*0a6a1f1dSLionel Sambuc   C::~C() {} // expected-error {{destructor cannot be declared using a typedef 'C' (aka 'const dr298::A') of the class name}}
1039*0a6a1f1dSLionel Sambuc 
1040*0a6a1f1dSLionel Sambuc   typedef struct D E; // expected-note {{here}}
1041*0a6a1f1dSLionel Sambuc   struct E {}; // expected-error {{conflicts with typedef}}
1042*0a6a1f1dSLionel Sambuc 
1043*0a6a1f1dSLionel Sambuc   struct F {
1044*0a6a1f1dSLionel Sambuc     ~F();
1045*0a6a1f1dSLionel Sambuc   };
1046*0a6a1f1dSLionel Sambuc   typedef const F G;
~F()1047*0a6a1f1dSLionel Sambuc   G::~F() {} // ok
1048*0a6a1f1dSLionel Sambuc }
1049*0a6a1f1dSLionel Sambuc 
1050*0a6a1f1dSLionel Sambuc namespace dr299 { // dr299: yes c++11
1051*0a6a1f1dSLionel Sambuc   struct S {
1052*0a6a1f1dSLionel Sambuc     operator int();
1053*0a6a1f1dSLionel Sambuc   };
1054*0a6a1f1dSLionel Sambuc   struct T {
1055*0a6a1f1dSLionel Sambuc     operator int(); // expected-note {{}}
1056*0a6a1f1dSLionel Sambuc     operator unsigned short(); // expected-note {{}}
1057*0a6a1f1dSLionel Sambuc   };
1058*0a6a1f1dSLionel Sambuc   // FIXME: should this apply to c++98 mode?
1059*0a6a1f1dSLionel Sambuc   int *p = new int[S()]; // expected-error 0-1{{extension}}
1060*0a6a1f1dSLionel Sambuc   int *q = new int[T()]; // expected-error {{ambiguous}}
1061*0a6a1f1dSLionel Sambuc }
1062