// RUN: %clang_cc1 -fsyntax-only %s typedef char one_byte; typedef char (&two_bytes)[2]; typedef char (&four_bytes)[4]; typedef char (&eight_bytes)[8]; template struct A { }; namespace N1 { struct X { }; } namespace N2 { struct Y { }; two_bytes operator+(Y, Y); } namespace N3 { struct Z { }; eight_bytes operator+(Z, Z); } namespace N4 { one_byte operator+(N1::X, N2::Y); template struct BinOpOverload { typedef A type; }; } namespace N1 { four_bytes operator+(X, X); } namespace N3 { eight_bytes operator+(Z, Z); // redeclaration } void test_bin_op_overload(A<1> *a1, A<2> *a2, A<4> *a4, A<8> *a8) { typedef N4::BinOpOverload::type XY; XY *xy = a1; typedef N4::BinOpOverload::type XX; XX *xx = a4; typedef N4::BinOpOverload::type YY; YY *yy = a2; typedef N4::BinOpOverload::type ZZ; ZZ *zz = a8; } namespace N3 { eight_bytes operator-(::N3::Z); } namespace N4 { template struct UnaryOpOverload { typedef A type; }; } void test_unary_op_overload(A<8> *a8) { typedef N4::UnaryOpOverload::type UZ; UZ *uz = a8; } /* namespace N5 { template struct Lookup { enum { val = I, more = val + 1 }; }; template struct Cond { enum Junk { is = B ? Lookup::more : Lookup::more>::val }; }; enum { resultT = Cond::is, resultF = Cond::is }; } */ namespace N6 { // non-typedependent template struct Lookup {}; template struct Cond { typedef Lookup True; typedef Lookup False; }; typedef Cond::True True; typedef Cond::False False; // check that we have the right types Lookup<1> const &L1(False()); Lookup const &L2(True()); } namespace N7 { // type dependent template struct Lookup {}; template struct Cond { T foo() { return B ? T() : E(); } typedef Lookup Type; }; //Cond C; // Errors //int V(C.foo()); // Errors //typedef Cond::Type Type; // Errors typedef Cond::Type Type; } template struct IntegralConstant { }; template struct X0 { void f(T x, IntegralConstant); }; void test_X0(X0 x, IntegralConstant ic) { x.f(5,ic); } namespace N8 { struct X { X operator+(const X&) const; }; template T test_plus(const T* xp, const T& x, const T& y) { x.operator+(y); return xp->operator+(y); } void test_test_plus(X x) { test_plus(&x, x, x); } } namespace N9 { struct A { bool operator==(int value); }; template struct B { bool f(A a) { return a == 1; } }; template struct B; } namespace N10 { template class A { struct X { }; public: ~A() { f(reinterpret_cast(0), reinterpret_cast(0)); } private: void f(X *); void f(X *, X *); }; template class A; } namespace N12 { // PR5224 template struct A { typedef int t0; }; struct C { C(int); template static C *f0(T a0) {return new C((typename A::t0) 1); } }; void f0(int **a) { C::f0(a); } } namespace PR7202 { template struct meta { typedef T type; }; struct X { struct dummy; template X(T, typename meta::type = 0); template X(T, A); }; template struct Z { }; template Z g(T); struct Y { template void f(T t) { new X(g(*this)); } }; template void Y::f(int); } namespace N13 { class A{ A(const A&); public: ~A(); A(int); template A &operator<<(const T&); }; template void f(T t) { A(17) << t; } template void f(int); }