Douglas Gregor | 786123d | 2010-05-21 23:18:07 +0000 | [diff] [blame] | 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 | |
Douglas Gregor | 20c38a7 | 2010-05-21 23:43:39 +0000 | [diff] [blame] | 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 | |
Douglas Gregor | 786123d | 2010-05-21 23:18:07 +0000 | [diff] [blame] | 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 | }; |
Douglas Gregor | 23648d7 | 2011-03-04 18:53:13 +0000 | [diff] [blame] | 19 | |
Richard Smith | 17c5947 | 2017-06-07 00:29:44 +0000 | [diff] [blame^] | 20 | struct MrsBadcrumble { |
| 21 | friend MrsBadcrumble operator<(void (*)(int), MrsBadcrumble); |
| 22 | friend void operator>(MrsBadcrumble, int); |
| 23 | } mb; |
| 24 | |
| 25 | template<int N, typename T> void f(T t) { |
| 26 | t.f<N>(0); // expected-error {{missing 'template' keyword prior to dependent template name 'f'}} |
| 27 | t.T::f<N>(0); // expected-error {{missing 'template' keyword prior to dependent template name 'f'}} |
| 28 | T::g<N>(0); // expected-error {{missing 'template' keyword prior to dependent template name 'g'}} |
| 29 | |
| 30 | // Note: no diagnostic here, this is actually valid as a comparison between |
| 31 | // the decayed pointer to Y::g<> and mb! |
| 32 | T::g<mb>(0); |
| 33 | } |
| 34 | |
| 35 | struct Y { |
| 36 | template <int> void f(int); |
| 37 | template <int = 0> static void g(int); // expected-warning 0-1{{extension}} |
| 38 | }; |
| 39 | void q() { void (*p)(int) = Y::g; } |
| 40 | template void f<0>(Y); // expected-note {{in instantiation of}} |
| 41 | |
Douglas Gregor | 23648d7 | 2011-03-04 18:53:13 +0000 | [diff] [blame] | 42 | namespace PR9401 { |
| 43 | // From GCC PR c++/45558 |
| 44 | template <typename S, typename T> |
| 45 | struct C |
| 46 | { |
| 47 | template <typename U> |
| 48 | struct B |
| 49 | { |
| 50 | template <typename W> |
| 51 | struct E |
| 52 | { |
| 53 | explicit E(const W &x) : w(x) {} |
| 54 | const W &w; |
| 55 | }; |
| 56 | }; |
| 57 | }; |
| 58 | |
| 59 | struct F; |
| 60 | template <typename X> |
| 61 | struct D |
| 62 | { |
| 63 | D() {} |
| 64 | }; |
| 65 | |
| 66 | const D<F> g; |
| 67 | template <typename S, typename T> |
| 68 | struct A |
| 69 | { |
| 70 | template <typename U> |
| 71 | struct B : C<S, T>::template B<U> |
| 72 | { |
| 73 | typedef typename C<S, T>::template B<U> V; |
| 74 | static const D<typename V::template E<D<F> > > a; |
| 75 | }; |
| 76 | }; |
| 77 | |
| 78 | template <typename S, typename T> |
| 79 | template <typename U> |
| 80 | const D<typename C<S, T>::template B<U>::template E<D<F> > > |
| 81 | A<S, T>::B<U>::a = typename C<S, T>::template B<U>::template E<D<F> >(g); |
| 82 | } |