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