Commit 867a3ea4 by Jason Merrill

new

From-SVN: r17612
parent 67da3287
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
};
// Build don't link:
template <class T>
struct S1
{
T* t;
static int foo;
};
struct S2 : public S1<S2>
{
S2* s;
};
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();
}
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();
}
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();
}
#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();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment