blob: 3f6fe343f5079f920b6aef1a512cf4bbc80e4a5f [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregord57959a2009-03-27 23:10:48 +00002namespace 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
16int i;
17
18typename N::A::type *ip1 = &i;
John McCall7c2342d2010-03-10 11:27:22 +000019typename N::B::type *ip2 = &i; // expected-error{{no type named 'type' in 'N::B'}}
Douglas Gregord57959a2009-03-27 23:10:48 +000020typename N::C::type *ip3 = &i; // expected-error{{typename specifier refers to non-type member 'type'}}
21
22void 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
33namespace N {
34 template<typename T>
35 struct X {
John McCall7c2342d2010-03-10 11:27:22 +000036 typedef typename T::type type; // expected-error {{no type named 'type' in 'N::B'}} \
37 // expected-error {{no type named 'type' in 'B'}} \
Douglas Gregord57959a2009-03-27 23:10:48 +000038 // 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
44N::X<N::A>::type *ip4 = &i;
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +000045N::X<N::B>::type *ip5 = &i; // expected-note{{in instantiation of template class 'N::X<N::B>' requested here}}
46N::X<N::C>::type *ip6 = &i; // expected-note{{in instantiation of template class 'N::X<N::C>' requested here}}
Douglas Gregord57959a2009-03-27 23:10:48 +000047
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +000048N::X<int>::type fail1; // expected-note{{in instantiation of template class 'N::X<int>' requested here}}
Douglas Gregord57959a2009-03-27 23:10:48 +000049
50template<typename T>
51struct Y {
John McCall7c2342d2010-03-10 11:27:22 +000052 typedef typename N::X<T>::type *type; // expected-note{{in instantiation of template class 'N::X<B>' requested here}} \
53 // expected-note{{in instantiation of template class 'N::X<C>' requested here}}
Douglas Gregord57959a2009-03-27 23:10:48 +000054};
55
56struct A {
57 typedef int type;
58};
59
60struct B {
61};
62
63struct C {
64 struct type { };
65 int type; // expected-note{{referenced member 'type' is declared here}}
66};
67
68::Y<A>::type ip7 = &i;
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +000069::Y<B>::type ip8 = &i; // expected-note{{in instantiation of template class 'Y<B>' requested here}}
70::Y<C>::type ip9 = &i; // expected-note{{in instantiation of template class 'Y<C>' requested here}}