Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Douglas Gregor | d57959a | 2009-03-27 23:10:48 +0000 | [diff] [blame] | 2 | namespace N { |
| 3 | struct A { |
| 4 | typedef int type; |
| 5 | }; |
| 6 | |
| 7 | struct B { |
| 8 | }; |
| 9 | |
| 10 | struct C { |
| 11 | struct type { }; |
| 12 | int type; // expected-note 2{{referenced member 'type' is declared here}} |
| 13 | }; |
| 14 | } |
| 15 | |
| 16 | int i; |
| 17 | |
| 18 | typename N::A::type *ip1 = &i; |
Douglas Gregor | 3f09327 | 2009-10-13 21:16:44 +0000 | [diff] [blame] | 19 | typename N::B::type *ip2 = &i; // expected-error{{no type named 'type' in 'struct N::B'}} |
Douglas Gregor | d57959a | 2009-03-27 23:10:48 +0000 | [diff] [blame] | 20 | typename N::C::type *ip3 = &i; // expected-error{{typename specifier refers to non-type member 'type'}} |
| 21 | |
| 22 | void test(double d) { |
| 23 | typename N::A::type f(typename N::A::type(a)); // expected-warning{{parentheses were disambiguated as a function declarator}} |
| 24 | int five = f(5); |
| 25 | |
| 26 | using namespace N; |
| 27 | for (typename A::type i = 0; i < 10; ++i) |
| 28 | five += 1; |
| 29 | |
| 30 | const typename N::A::type f2(d); |
| 31 | } |
| 32 | |
| 33 | namespace N { |
| 34 | template<typename T> |
| 35 | struct X { |
Douglas Gregor | 3f09327 | 2009-10-13 21:16:44 +0000 | [diff] [blame] | 36 | typedef typename T::type type; // expected-error {{no type named 'type' in 'struct N::B'}} \ |
| 37 | // expected-error {{no type named 'type' in 'struct B'}} \ |
Douglas Gregor | d57959a | 2009-03-27 23:10:48 +0000 | [diff] [blame] | 38 | // FIXME: location info for error above isn't very good \ |
| 39 | // expected-error 2{{typename specifier refers to non-type member 'type'}} \ |
| 40 | // expected-error{{type 'int' cannot be used prior to '::' because it has no members}} |
| 41 | }; |
| 42 | } |
| 43 | |
| 44 | N::X<N::A>::type *ip4 = &i; |
| 45 | N::X<N::B>::type *ip5 = &i; // expected-note{{in instantiation of template class 'struct N::X<struct N::B>' requested here}} \ |
Douglas Gregor | a786fdb | 2009-10-13 23:27:22 +0000 | [diff] [blame] | 46 | // expected-error{{no type named 'type' in}} |
Douglas Gregor | d57959a | 2009-03-27 23:10:48 +0000 | [diff] [blame] | 47 | N::X<N::C>::type *ip6 = &i; // expected-note{{in instantiation of template class 'struct N::X<struct N::C>' requested here}} \ |
Douglas Gregor | a786fdb | 2009-10-13 23:27:22 +0000 | [diff] [blame] | 48 | // expected-error{{no type named 'type' in}} |
Douglas Gregor | d57959a | 2009-03-27 23:10:48 +0000 | [diff] [blame] | 49 | |
| 50 | N::X<int>::type fail1; // expected-note{{in instantiation of template class 'struct N::X<int>' requested here}} \ |
Douglas Gregor | a786fdb | 2009-10-13 23:27:22 +0000 | [diff] [blame] | 51 | // expected-error{{no type named 'type' in}} |
Douglas Gregor | d57959a | 2009-03-27 23:10:48 +0000 | [diff] [blame] | 52 | |
| 53 | template<typename T> |
| 54 | struct Y { |
| 55 | typedef typename N::X<T>::type *type; // expected-note{{in instantiation of template class 'struct N::X<struct B>' requested here}} \ |
| 56 | // expected-note{{in instantiation of template class 'struct N::X<struct C>' requested here}} |
| 57 | }; |
| 58 | |
| 59 | struct A { |
| 60 | typedef int type; |
| 61 | }; |
| 62 | |
| 63 | struct B { |
| 64 | }; |
| 65 | |
| 66 | struct C { |
| 67 | struct type { }; |
| 68 | int type; // expected-note{{referenced member 'type' is declared here}} |
| 69 | }; |
| 70 | |
| 71 | ::Y<A>::type ip7 = &i; |
| 72 | ::Y<B>::type ip8 = &i; // expected-note{{in instantiation of template class 'struct Y<struct B>' requested here}} \ |
Douglas Gregor | a786fdb | 2009-10-13 23:27:22 +0000 | [diff] [blame] | 73 | // expected-error{{no type named 'type' in}} |
Douglas Gregor | d57959a | 2009-03-27 23:10:48 +0000 | [diff] [blame] | 74 | ::Y<C>::type ip9 = &i; // expected-note{{in instantiation of template class 'struct Y<struct C>' requested here}} \ |
Douglas Gregor | a786fdb | 2009-10-13 23:27:22 +0000 | [diff] [blame] | 75 | // expected-error{{no type named 'type' in}} |