instantiate-member-class.cpp [plain text]
namespace PR8965 {
template<typename T>
struct X {
typedef int type;
T field; };
template<typename T>
struct Y {
struct Inner;
typedef typename X<Inner>::type type;
struct Inner {
typedef type field; };
};
Y<int> y; }
template<typename T>
class X {
public:
struct C { T &foo(); };
struct D {
struct E { T &bar(); }; struct F; };
};
X<int>::C *c1;
X<float>::C *c2;
X<int>::X *xi; X<float>::X *xf;
void test_naming() {
c1 = c2; xi = xf; }
void test_instantiation(X<double>::C *x,
X<float>::D::E *e,
X<float>::D::F *f) {
double &dr = x->foo();
float &fr = e->bar();
f->foo();
}
X<void>::C *c3; X<void>::D::E *e1; X<void>::D::E e2;
namespace test1 {
template <typename T> struct Registry {
struct node;
static node *Head;
struct node {
node(int v) { Head = this; }
};
};
void test() {
Registry<int>::node node(0);
}
}
namespace test2 {
template <typename T> class A {
class Foo;
class Foo {
int foo();
};
};
template class A<int>;
template <typename T> class B {
class Foo;
class Foo {
public:
typedef int X;
};
typename Foo::X x;
class Foo;
};
template class B<int>;
template <typename T> class C {
class Foo;
class Foo;
};
template <typename T> class C<T>::Foo {
int x;
};
template class C<int>;
}
namespace AliasTagDef {
template<typename T>
struct F {
using S = struct U { T g() {
return T();
}
};
};
int m = F<int>::S().g();
int n = F<int>::U().g();
}
namespace rdar10397846 {
template<int I> struct A
{
struct B
{
struct C { C() { int *ptr = I; } }; expected-warning{{expression which evaluates to zero treated as a null pointer constant of type 'int *'}}
};
};
template<int N> void foo()
{
class A<N>::B::C X; int A<N+1>::B::C::*member = 0;
}
void bar()
{
foo<0>(); foo<1>(); }
}