From-SVN: r17612
This commit is contained in:
Jason Merrill 1998-02-02 20:33:18 -05:00
parent 67da32876e
commit 867a3ea4fb
6 changed files with 142 additions and 0 deletions

View File

@ -0,0 +1,11 @@
template<class T> class A {
public:
class subA {};
};
template<class T> class B : public A<T> {
public:
class subB : public A::subA {}; // ERROR - not a class or namespace
};

View File

@ -0,0 +1,14 @@
// Build don't link:
template <class T>
struct S1
{
T* t;
static int foo;
};
struct S2 : public S1<S2>
{
S2* s;
};

View File

@ -0,0 +1,24 @@
extern "C" void abort();
template <class T>
int f(T)
{
struct S1 {
virtual int foo() { return 1; }
};
struct S2 : public S1 {
int foo() { return 2; }
};
S1* s2 = new S2;
return s2->foo();
}
int main()
{
if (f(3) != 2)
abort();
}

View File

@ -0,0 +1,49 @@
extern "C" void abort();
template <class T>
struct S1
{
static void f();
};
template <>
void S1<int>::f() {}
struct S2
{
template <class T>
static void g(T);
};
template <>
void S2::g(double) {}
template <>
void S2::g<int>(int) {}
template <class T>
struct S3
{
template <class U>
static int h(U);
};
template <class T>
template <>
int S3<T>::h(int) { return 0; }
template <>
template <>
int S3<char>::h(int) { return 1; }
int main()
{
S1<int>::f();
S2::g(3.0);
S2::g(7);
if (S3<double>::h(7) != 0)
abort();
if (S3<char>::h(7) != 1)
abort();
}

View File

@ -0,0 +1,16 @@
extern "C" void abort();
template <class T>
T f(T)
{
T t = __extension__ ({ T j = 4; j + 3; });
return t;
}
int main()
{
if (f(3) != 7)
abort();
}

View File

@ -0,0 +1,28 @@
#include <stdarg.h>
extern "C" void abort();
template <class T>
T* f(T t, ...)
{
va_list ap;
va_start(ap, t);
T* r = va_arg(ap, T*);
va_end(ap);
return r;
}
struct S
{
};
int main()
{
S s;
if (f(s, &s) != &s)
abort();
}