xref: /minix3/external/bsd/llvm/dist/clang/test/SemaTemplate/dependent-template-recover.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc template<typename T, typename U, int N>
3*f4a2713aSLionel Sambuc struct X {
fX4*f4a2713aSLionel Sambuc   void f(T* t) {
5*f4a2713aSLionel Sambuc     t->f0<U>(); // expected-error{{use 'template' keyword to treat 'f0' as a dependent template name}}
6*f4a2713aSLionel Sambuc     t->f0<int>(); // expected-error{{use 'template' keyword to treat 'f0' as a dependent template name}}
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc     t->operator+<U const, 1>(); // expected-error{{use 'template' keyword to treat 'operator +' as a dependent template name}}
9*f4a2713aSLionel Sambuc     t->f1<int const, 2>(); // expected-error{{use 'template' keyword to treat 'f1' as a dependent template name}}
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc     T::getAs<U>(); // expected-error{{use 'template' keyword to treat 'getAs' as a dependent template name}}
12*f4a2713aSLionel Sambuc     t->T::getAs<U>(); // expected-error{{use 'template' keyword to treat 'getAs' as a dependent template name}}
13*f4a2713aSLionel Sambuc 
14*f4a2713aSLionel Sambuc     // FIXME: We can't recover from these yet
15*f4a2713aSLionel Sambuc     (*t).f2<N>(); // expected-error{{expected expression}}
16*f4a2713aSLionel Sambuc     (*t).f2<0>(); // expected-error{{expected expression}}
17*f4a2713aSLionel Sambuc   }
18*f4a2713aSLionel Sambuc };
19*f4a2713aSLionel Sambuc 
20*f4a2713aSLionel Sambuc namespace PR9401 {
21*f4a2713aSLionel Sambuc   // From GCC PR c++/45558
22*f4a2713aSLionel Sambuc   template <typename S, typename T>
23*f4a2713aSLionel Sambuc   struct C
24*f4a2713aSLionel Sambuc   {
25*f4a2713aSLionel Sambuc     template <typename U>
26*f4a2713aSLionel Sambuc     struct B
27*f4a2713aSLionel Sambuc     {
28*f4a2713aSLionel Sambuc       template <typename W>
29*f4a2713aSLionel Sambuc       struct E
30*f4a2713aSLionel Sambuc       {
EPR9401::C::B::E31*f4a2713aSLionel Sambuc         explicit E(const W &x) : w(x) {}
32*f4a2713aSLionel Sambuc         const W &w;
33*f4a2713aSLionel Sambuc       };
34*f4a2713aSLionel Sambuc     };
35*f4a2713aSLionel Sambuc   };
36*f4a2713aSLionel Sambuc 
37*f4a2713aSLionel Sambuc   struct F;
38*f4a2713aSLionel Sambuc   template <typename X>
39*f4a2713aSLionel Sambuc   struct D
40*f4a2713aSLionel Sambuc   {
DPR9401::D41*f4a2713aSLionel Sambuc     D() {}
42*f4a2713aSLionel Sambuc   };
43*f4a2713aSLionel Sambuc 
44*f4a2713aSLionel Sambuc   const D<F> g;
45*f4a2713aSLionel Sambuc   template <typename S, typename T>
46*f4a2713aSLionel Sambuc   struct A
47*f4a2713aSLionel Sambuc   {
48*f4a2713aSLionel Sambuc     template <typename U>
49*f4a2713aSLionel Sambuc     struct B : C<S, T>::template B<U>
50*f4a2713aSLionel Sambuc     {
51*f4a2713aSLionel Sambuc       typedef typename C<S, T>::template B<U> V;
52*f4a2713aSLionel Sambuc       static const D<typename V::template E<D<F> > > a;
53*f4a2713aSLionel Sambuc     };
54*f4a2713aSLionel Sambuc   };
55*f4a2713aSLionel Sambuc 
56*f4a2713aSLionel Sambuc   template <typename S, typename T>
57*f4a2713aSLionel Sambuc   template <typename U>
58*f4a2713aSLionel Sambuc   const D<typename C<S, T>::template B<U>::template E<D<F> > >
59*f4a2713aSLionel Sambuc   A<S, T>::B<U>::a = typename C<S, T>::template B<U>::template E<D<F> >(g);
60*f4a2713aSLionel Sambuc }
61