blob: 81af5730def41fb955fae03d4591a6e04fa9044f [file] [log] [blame]
Douglas Gregor07606362009-03-13 21:04:12 +00001// RUN: clang -fsyntax-only %s
2typedef char one_byte;
3typedef char (&two_bytes)[2];
4typedef char (&four_bytes)[4];
5typedef char (&eight_bytes)[8];
6
7template<int N> struct A { };
8
9namespace N1 {
10 struct X { };
11}
12
13namespace N2 {
14 struct Y { };
15
16 two_bytes operator+(Y, Y);
17}
18
19namespace N3 {
20 struct Z { };
21
22 eight_bytes operator+(Z, Z);
23}
24
25namespace N4 {
26 one_byte operator+(N1::X, N2::Y);
27
28 template<typename T, typename U>
29 struct BinOpOverload {
30 typedef A<sizeof(T() + U())> type;
31 };
32}
33
34namespace N1 {
35 four_bytes operator+(X, X);
36}
37
38namespace N3 {
39 eight_bytes operator+(Z, Z); // redeclaration
40}
41
42void 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;
44 XY *xy = a1;
45 typedef N4::BinOpOverload<N1::X, N1::X>::type XX;
46 XX *xx = a4;
47 typedef N4::BinOpOverload<N2::Y, N2::Y>::type YY;
48 YY *yy = a2;
49 typedef N4::BinOpOverload<N3::Z, N3::Z>::type ZZ;
50 ZZ *zz = a8;
51}
52