xref: /minix3/external/bsd/llvm/dist/clang/test/SemaTemplate/dependent-base-member-init.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc // expected-no-diagnostics
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc // PR4381
5*f4a2713aSLionel Sambuc template<class T> struct X {};
6*f4a2713aSLionel Sambuc template<typename T> struct Y : public X<T>::X { };
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc // PR4621
9*f4a2713aSLionel Sambuc class A1 {
A1(int x)10*f4a2713aSLionel Sambuc   A1(int x) {}
11*f4a2713aSLionel Sambuc };
12*f4a2713aSLionel Sambuc template<class C> class B1 : public A1 {
B1(C x)13*f4a2713aSLionel Sambuc   B1(C x) : A1(x.x) {}
14*f4a2713aSLionel Sambuc };
15*f4a2713aSLionel Sambuc class A2 { A2(int x, int y); };
16*f4a2713aSLionel Sambuc template <class C> class B2 {
17*f4a2713aSLionel Sambuc   A2 x;
B2(C x)18*f4a2713aSLionel Sambuc   B2(C x) : x(x.x, x.y) {}
19*f4a2713aSLionel Sambuc };
20*f4a2713aSLionel Sambuc template <class C> class B3 {
21*f4a2713aSLionel Sambuc   C x;
B3()22*f4a2713aSLionel Sambuc   B3() : x(1,2) {}
23*f4a2713aSLionel Sambuc };
24*f4a2713aSLionel Sambuc 
25*f4a2713aSLionel Sambuc // PR4627
26*f4a2713aSLionel Sambuc template<typename _Container> class insert_iterator {
27*f4a2713aSLionel Sambuc     _Container* container;
insert_iterator(_Container & __x)28*f4a2713aSLionel Sambuc     insert_iterator(_Container& __x) : container(&__x) {}
29*f4a2713aSLionel Sambuc };
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc // PR4763
32*f4a2713aSLionel Sambuc template<typename T> struct s0 {};
33*f4a2713aSLionel Sambuc template<typename T> struct s0_traits {};
34*f4a2713aSLionel Sambuc template<typename T> struct s1 : s0<typename s0_traits<T>::t0> {
s1s135*f4a2713aSLionel Sambuc   s1() {}
36*f4a2713aSLionel Sambuc };
37*f4a2713aSLionel Sambuc 
38*f4a2713aSLionel Sambuc // PR6062
39*f4a2713aSLionel Sambuc namespace PR6062 {
40*f4a2713aSLionel Sambuc   template <typename T>
41*f4a2713aSLionel Sambuc   class A : public T::type
42*f4a2713aSLionel Sambuc   {
A()43*f4a2713aSLionel Sambuc     A() : T::type()
44*f4a2713aSLionel Sambuc     {
45*f4a2713aSLionel Sambuc     }
46*f4a2713aSLionel Sambuc 
47*f4a2713aSLionel Sambuc     template <typename U>
A(U const & init)48*f4a2713aSLionel Sambuc     A(U const& init)
49*f4a2713aSLionel Sambuc       : T::type(init)
50*f4a2713aSLionel Sambuc     { }
51*f4a2713aSLionel Sambuc 
52*f4a2713aSLionel Sambuc     template<typename U>
A(U & init)53*f4a2713aSLionel Sambuc     A(U& init) : U::other_type(init) { }
54*f4a2713aSLionel Sambuc   };
55*f4a2713aSLionel Sambuc }
56*f4a2713aSLionel Sambuc 
57*f4a2713aSLionel Sambuc template<typename T, typename U>
58*f4a2713aSLionel Sambuc struct X0 : T::template apply<U> {
X0X059*f4a2713aSLionel Sambuc   X0(int i) : T::template apply<U>(i) { }
60*f4a2713aSLionel Sambuc };
61*f4a2713aSLionel Sambuc 
62*f4a2713aSLionel Sambuc // PR7698
63*f4a2713aSLionel Sambuc namespace PR7698 {
64*f4a2713aSLionel Sambuc   template<typename Type>
65*f4a2713aSLionel Sambuc   class A {
66*f4a2713aSLionel Sambuc     char mA[sizeof(Type *)];
A()67*f4a2713aSLionel Sambuc     A(): mA() {}
68*f4a2713aSLionel Sambuc   };
69*f4a2713aSLionel Sambuc }
70