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