From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- .../SemaTemplate/member-template-access-expr.cpp | 144 +++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 clang/test/SemaTemplate/member-template-access-expr.cpp (limited to 'clang/test/SemaTemplate/member-template-access-expr.cpp') diff --git a/clang/test/SemaTemplate/member-template-access-expr.cpp b/clang/test/SemaTemplate/member-template-access-expr.cpp new file mode 100644 index 0000000..c95b57d --- /dev/null +++ b/clang/test/SemaTemplate/member-template-access-expr.cpp @@ -0,0 +1,144 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +template +U f0(T t) { + return t.template get(); +} + +template +int &f1(T t) { + // FIXME: When we pretty-print this, we lose the "template" keyword. + return t.U::template get(); +} + +struct X { + template T get(); +}; + +void test_f0(X x) { + int i = f0(x); + int &ir = f0(x); +} + +struct XDerived : public X { +}; + +void test_f1(XDerived xd) { + int &ir = f1(xd); +} + +// PR5213 +template +struct A {}; + +template +class B +{ + A a_; + +public: + void destroy(); +}; + +template +void +B::destroy() +{ + a_.~A(); +} + +void do_destroy_B(B b) { + b.destroy(); +} + +struct X1 { + int* f1(int); + template float* f1(T); + + static int* f2(int); + template static float* f2(T); +}; + +void test_X1(X1 x1) { + float *fp1 = x1.f1<>(17); + float *fp2 = x1.f1(3.14); // expected-warning {{implicit conversion turns literal floating-point number into integer}} + int *ip1 = x1.f1(17); + float *ip2 = x1.f1(3.14); + + float* (X1::*mf1)(int) = &X1::f1; + float* (X1::*mf2)(int) = &X1::f1<>; + float* (X1::*mf3)(float) = &X1::f1; + + float* (*fp3)(int) = &X1::f2; + float* (*fp4)(int) = &X1::f2<>; + float* (*fp5)(float) = &X1::f2; + float* (*fp6)(int) = X1::f2; + float* (*fp7)(int) = X1::f2<>; + float* (*fp8)(float) = X1::f2; +} + +template struct X2 { + int m; +}; + +template +struct X3 : T { }; + +template +struct X4 { + template + void f(X2().U::m)>); +}; + +void f(X4 > x4i) { + X2 x2; + x4i.f >(x2); +} + +template +struct X5 { + template + void f(); + + void g() { + this->f(); + } +}; + +namespace PR6021 { + template< class T1, class T2 > + class Outer + { + public: // Range operations + template< class X > X tmpl( const X* = 0 ) const; + + struct Inner + { + const Outer& o; + + template< class X > + operator X() const + { + return o.tmpl(); + } + }; + }; +} + +namespace rdar8198511 { + template + struct Base { + void f(); + }; + + template + struct X0 : Base<1, T> { }; + + template + struct X1 { + X0 x0; + + void f() { + this->x0.Base<1, int>::f(); + } + }; +} -- cgit v1.2.3