Matt Beaumont-Gay | 09f3462 | 2011-02-25 19:09:01 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Douglas Gregor | 5149f37 | 2011-02-25 15:54:31 +0000 | [diff] [blame] | 2 | |
| 3 | // Note: the formatting in this test case is intentionally funny, with |
| 4 | // nested-name-specifiers stretched out vertically so that we can |
| 5 | // match up diagnostics per-line and still verify that we're getting |
| 6 | // good source-location information. |
| 7 | |
| 8 | namespace outer { |
| 9 | namespace inner { |
| 10 | template<typename T> |
| 11 | struct X0 { |
| 12 | }; |
| 13 | } |
| 14 | } |
| 15 | |
| 16 | template<typename T> |
| 17 | struct add_reference { |
| 18 | typedef T& type; |
| 19 | }; |
| 20 | |
| 21 | namespace outer_alias = outer; |
| 22 | |
| 23 | template<typename T> |
| 24 | struct UnresolvedUsingValueDeclTester { |
| 25 | using outer::inner::X0< |
| 26 | typename add_reference<T>::type |
| 27 | * // expected-error{{declared as a pointer to a reference of type}} |
| 28 | >::value; |
| 29 | }; |
| 30 | |
| 31 | UnresolvedUsingValueDeclTester<int> UnresolvedUsingValueDeclCheck; // expected-note{{in instantiation of template class}} |
| 32 | |
| 33 | template<typename T> |
| 34 | struct UnresolvedUsingTypenameDeclTester { |
| 35 | using outer::inner::X0< |
| 36 | typename add_reference<T>::type |
| 37 | * // expected-error{{declared as a pointer to a reference of type}} |
| 38 | >::value; |
| 39 | }; |
| 40 | |
| 41 | UnresolvedUsingTypenameDeclTester<int> UnresolvedUsingTypenameDeclCheck; // expected-note{{in instantiation of template class}} |
| 42 | |
Douglas Gregor | f3db29f | 2011-02-25 18:19:59 +0000 | [diff] [blame] | 43 | |
| 44 | template<typename T, typename U> |
| 45 | struct PseudoDestructorExprTester { |
| 46 | void f(T *t) { |
| 47 | t->T::template Inner<typename add_reference<U>::type |
| 48 | * // expected-error{{as a pointer to a reference of type}} |
| 49 | >::Blarg::~Blarg(); |
| 50 | } |
| 51 | }; |
| 52 | |
| 53 | struct HasInnerTemplate { |
| 54 | template<typename T> |
| 55 | struct Inner; |
| 56 | |
| 57 | typedef HasInnerTemplate T; |
| 58 | }; |
| 59 | |
| 60 | void PseudoDestructorExprCheck( |
| 61 | PseudoDestructorExprTester<HasInnerTemplate, float> tester) { |
| 62 | tester.f(0); // expected-note{{in instantiation of member function}} |
| 63 | } |
Douglas Gregor | 00cf3cc | 2011-02-25 20:49:16 +0000 | [diff] [blame] | 64 | |
| 65 | template<typename T> |
| 66 | struct DependentScopedDeclRefExpr { |
| 67 | void f() { |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 68 | outer_alias::inner::X0<typename add_reference<T>::type |
| 69 | * // expected-error{{as a pointer to a reference of type}} |
| 70 | >::value = 17; |
Douglas Gregor | 00cf3cc | 2011-02-25 20:49:16 +0000 | [diff] [blame] | 71 | } |
| 72 | }; |
Douglas Gregor | 7c3179c | 2011-02-28 18:50:33 +0000 | [diff] [blame] | 73 | |
| 74 | void DependentScopedDeclRefExprCheck(DependentScopedDeclRefExpr<int> t) { |
| 75 | t.f(); // expected-note{{in instantiation of member function}} |
| 76 | } |
Douglas Gregor | 2494dd0 | 2011-03-01 01:34:45 +0000 | [diff] [blame^] | 77 | |
| 78 | |
| 79 | template<typename T> |
| 80 | struct TypenameTypeTester { |
| 81 | typedef typename outer::inner::X0< |
| 82 | typename add_reference<T>::type |
| 83 | * // expected-error{{declared as a pointer to a reference of type}} |
| 84 | >::type type; |
| 85 | }; |
| 86 | |
| 87 | TypenameTypeTester<int> TypenameTypeCheck; // expected-note{{in instantiation of template class}} |