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). --- .../test/SemaTemplate/member-function-template.cpp | 103 +++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 clang/test/SemaTemplate/member-function-template.cpp (limited to 'clang/test/SemaTemplate/member-function-template.cpp') diff --git a/clang/test/SemaTemplate/member-function-template.cpp b/clang/test/SemaTemplate/member-function-template.cpp new file mode 100644 index 0000000..44954ed --- /dev/null +++ b/clang/test/SemaTemplate/member-function-template.cpp @@ -0,0 +1,103 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +struct X { + template T& f0(T); + + void g0(int i, double d) { + int &ir = f0(i); + double &dr = f0(d); + } + + template T& f1(T); + template U& f1(T, U); + + void g1(int i, double d) { + int &ir1 = f1(i); + int &ir2 = f1(d, i); + int &ir3 = f1(i, i); + } +}; + +void test_X_f0(X x, int i, float f) { + int &ir = x.f0(i); + float &fr = x.f0(f); +} + +void test_X_f1(X x, int i, float f) { + int &ir1 = x.f1(i); + int &ir2 = x.f1(f, i); + int &ir3 = x.f1(i, i); +} + +void test_X_f0_address() { + int& (X::*pm1)(int) = &X::f0; + float& (X::*pm2)(float) = &X::f0; +} + +void test_X_f1_address() { + int& (X::*pm1)(int) = &X::f1; + float& (X::*pm2)(float) = &X::f1; + int& (X::*pm3)(float, int) = &X::f1; +} + +void test_X_f0_explicit(X x, int i, long l) { + int &ir1 = x.f0(i); + int &ir2 = x.f0<>(i); + long &il1 = x.f0(i); +} + +// PR4608 +class A { template x a(x z) { return z+y; } int y; }; + +// PR5419 +struct Functor { + template + bool operator()(const T& v) const { + return true; + } +}; + +void test_Functor(Functor f) { + f(1); +} + +// Instantiation on -> +template +struct X1 { + template U& get(); +}; + +template struct X2; // expected-note{{here}} + +void test_incomplete_access(X1 *x1, X2 *x2) { + float &fr = x1->get(); + (void)x2->get(); // expected-error{{implicit instantiation of undefined template}} +} + +// Instantiation of template template parameters in a member function +// template. +namespace TTP { + template struct X { + template class M, class T> void f(const M&); + }; + + template struct Y { }; + + void test_f(X<3> x, Y y) { x.f(y); } +} + +namespace PR7387 { + template struct X {}; + + template struct S { + template