dependent-template-recover.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. t->operator+<U const, 1>(); // expected-error{{use 'template' keyword to treat 'operator +' as a dependent template name}}
  8. t->f1<int const, 2>(); // expected-error{{use 'template' keyword to treat 'f1' as a dependent template name}}
  9. T::getAs<U>(); // expected-error{{use 'template' keyword to treat 'getAs' as a dependent template name}}
  10. t->T::getAs<U>(); // expected-error{{use 'template' keyword to treat 'getAs' as a dependent template name}}
  11. // FIXME: We can't recover from these yet
  12. (*t).f2<N>(); // expected-error{{expected expression}}
  13. (*t).f2<0>(); // expected-error{{expected expression}}
  14. }
  15. };
  16. namespace PR9401 {
  17. // From GCC PR c++/45558
  18. template <typename S, typename T>
  19. struct C
  20. {
  21. template <typename U>
  22. struct B
  23. {
  24. template <typename W>
  25. struct E
  26. {
  27. explicit E(const W &x) : w(x) {}
  28. const W &w;
  29. };
  30. };
  31. };
  32. struct F;
  33. template <typename X>
  34. struct D
  35. {
  36. D() {}
  37. };
  38. const D<F> g;
  39. template <typename S, typename T>
  40. struct A
  41. {
  42. template <typename U>
  43. struct B : C<S, T>::template B<U>
  44. {
  45. typedef typename C<S, T>::template B<U> V;
  46. static const D<typename V::template E<D<F> > > a;
  47. };
  48. };
  49. template <typename S, typename T>
  50. template <typename U>
  51. const D<typename C<S, T>::template B<U>::template E<D<F> > >
  52. A<S, T>::B<U>::a = typename C<S, T>::template B<U>::template E<D<F> >(g);
  53. }