1 // RUN: %clang_cc1 -fsyntax-only %s
3 typedef char (&two_bytes
)[2];
4 typedef char (&four_bytes
)[4];
5 typedef char (&eight_bytes
)[8];
7 template<int N
> struct A
{ };
16 two_bytes
operator+(Y
, Y
);
22 eight_bytes
operator+(Z
, Z
);
26 one_byte
operator+(N1::X
, N2::Y
);
28 template<typename T
, typename U
>
29 struct BinOpOverload
{
30 typedef A
<sizeof(T() + U())> type
;
35 four_bytes
operator+(X
, X
);
39 eight_bytes
operator+(Z
, Z
); // redeclaration
42 void test_bin_op_overload(A
<1> *a1
, A
<2> *a2
, A
<4> *a4
, A
<8> *a8
) {
43 typedef N4::BinOpOverload
<N1::X
, N2::Y
>::type XY
;
45 typedef N4::BinOpOverload
<N1::X
, N1::X
>::type XX
;
47 typedef N4::BinOpOverload
<N2::Y
, N2::Y
>::type YY
;
49 typedef N4::BinOpOverload
<N3::Z
, N3::Z
>::type ZZ
;
54 eight_bytes
operator-(::N3::Z
);
59 struct UnaryOpOverload
{
60 typedef A
<sizeof(-T())> type
;
64 void test_unary_op_overload(A
<8> *a8
) {
65 typedef N4::UnaryOpOverload
<N3::Z
>::type UZ
;
73 enum { val = I, more = val + 1 };
78 enum Junk { is = B ? Lookup<B>::more : Lookup<Lookup<B+1>::more>::val };
81 enum { resultT = Cond<true>::is,
82 resultF = Cond<false>::is };
91 template<bool B
, typename T
, typename E
>
93 typedef Lookup
<B
? sizeof(T
) : sizeof(E
)> True
;
94 typedef Lookup
<!B
? sizeof(T
) : sizeof(E
)> False
;
97 typedef Cond
<true, int, char>::True True
;
98 typedef Cond
<true, int, char>::False False
;
100 // check that we have the right types
101 Lookup
<1> const &L1(False());
102 Lookup
<sizeof(int)> const &L2(True());
111 template<bool B
, typename T
, typename E
>
113 T
foo() { return B
? T() : E(); }
114 typedef Lookup
<sizeof(B
? T() : E())> Type
;
117 //Cond<true, int*, double> C; // Errors
118 //int V(C.foo()); // Errors
119 //typedef Cond<true, int*, double>::Type Type; // Errors
120 typedef Cond
<true, int, double>::Type Type
;
123 template<typename T
, unsigned long N
> struct IntegralConstant
{ };
127 void f(T x
, IntegralConstant
<T
, sizeof(x
)>);
130 void test_X0(X0
<int> x
, IntegralConstant
<int, sizeof(int)> ic
) {
136 X
operator+(const X
&) const;
140 T
test_plus(const T
* xp
, const T
& x
, const T
& y
) {
142 return xp
->operator+(y
);
145 void test_test_plus(X x
) {
152 bool operator==(int value
);
155 template<typename T
> struct B
{
161 template struct B
<int>;
165 template <typename T
>
171 f(reinterpret_cast<X
*>(0), reinterpret_cast<X
*>(0));
179 template class A
<int>;
185 struct A
{ typedef int t0
; };
191 static C
*f0(T a0
) {return new C((typename A
<T
>::t0
) 1); }
194 void f0(int **a
) { C::f0(a
); }
198 template<typename U
, typename T
>
207 X(T
, typename meta
<T
, dummy
*>::type
= 0);
209 template<typename T
, typename A
>
216 template<typename T
> Z
<T
> g(T
);
225 template void Y::f(int);
235 template<typename T
> A
&operator<<(const T
&);
243 template void f(int);