diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-03-13 21:04:12 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-03-13 21:04:12 +0000 |
commit | 4b7f3d7344dc1a3bde6b033000bffabb51f021e7 (patch) | |
tree | 3d8d60ebbdd90b5cd7b5605c1d2d4eb5a338752c /clang/test/SemaTemplate/instantiate-expr-2.cpp | |
parent | c178c5f1265abcd52f0100fcd8b3e57a8fbab4ba (diff) | |
download | bcm5719-llvm-4b7f3d7344dc1a3bde6b033000bffabb51f021e7.tar.gz bcm5719-llvm-4b7f3d7344dc1a3bde6b033000bffabb51f021e7.zip |
Devious test-case involved overload resolution and ADL during template instantiation.
llvm-svn: 66951
Diffstat (limited to 'clang/test/SemaTemplate/instantiate-expr-2.cpp')
-rw-r--r-- | clang/test/SemaTemplate/instantiate-expr-2.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/clang/test/SemaTemplate/instantiate-expr-2.cpp b/clang/test/SemaTemplate/instantiate-expr-2.cpp new file mode 100644 index 00000000000..81af5730def --- /dev/null +++ b/clang/test/SemaTemplate/instantiate-expr-2.cpp @@ -0,0 +1,52 @@ +// RUN: clang -fsyntax-only %s +typedef char one_byte; +typedef char (&two_bytes)[2]; +typedef char (&four_bytes)[4]; +typedef char (&eight_bytes)[8]; + +template<int N> 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<typename T, typename U> + struct BinOpOverload { + typedef A<sizeof(T() + U())> 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<N1::X, N2::Y>::type XY; + XY *xy = a1; + typedef N4::BinOpOverload<N1::X, N1::X>::type XX; + XX *xx = a4; + typedef N4::BinOpOverload<N2::Y, N2::Y>::type YY; + YY *yy = a2; + typedef N4::BinOpOverload<N3::Z, N3::Z>::type ZZ; + ZZ *zz = a8; +} + |