blob: d15dbbc6e93a637110d321f2ddf5cfbaedff6d5b [file] [log] [blame]
Douglas Gregord57959a2009-03-27 23:10:48 +00001// RUN: clang-cc -fsyntax-only -verify %s
2namespace 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;
19typename N::B::type *ip2 = &i; // expected-error{{ no type named 'type' in 'B'}}
20typename 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 {
36 typedef typename T::type type; // expected-error 2{{no type named 'type' in 'B'}} \
37 // FIXME: location info for error above isn't very good \
38 // expected-error 2{{typename specifier refers to non-type member 'type'}} \
39 // expected-error{{type 'int' cannot be used prior to '::' because it has no members}}
40 };
41}
42
43N::X<N::A>::type *ip4 = &i;
44N::X<N::B>::type *ip5 = &i; // expected-note{{in instantiation of template class 'struct N::X<struct N::B>' requested here}} \
45// FIXME: expected-error{{invalid token after top level declarator}}
46N::X<N::C>::type *ip6 = &i; // expected-note{{in instantiation of template class 'struct N::X<struct N::C>' requested here}} \
47// FIXME: expected-error{{invalid token after top level declarator}}
48
49N::X<int>::type fail1; // expected-note{{in instantiation of template class 'struct N::X<int>' requested here}} \
50// FIXME: expected-error{{invalid token after top level declarator}}
51
52template<typename T>
53struct Y {
54 typedef typename N::X<T>::type *type; // expected-note{{in instantiation of template class 'struct N::X<struct B>' requested here}} \
55 // expected-note{{in instantiation of template class 'struct N::X<struct C>' requested here}}
56};
57
58struct A {
59 typedef int type;
60};
61
62struct B {
63};
64
65struct C {
66 struct type { };
67 int type; // expected-note{{referenced member 'type' is declared here}}
68};
69
70::Y<A>::type ip7 = &i;
71::Y<B>::type ip8 = &i; // expected-note{{in instantiation of template class 'struct Y<struct B>' requested here}} \
72// FIXME: expected-error{{invalid token after top level declarator}}
73::Y<C>::type ip9 = &i; // expected-note{{in instantiation of template class 'struct Y<struct C>' requested here}} \
74// FIXME: expected-error{{invalid token after top level declarator}}