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). --- clang/test/SemaTemplate/temp_func_order.cpp | 95 +++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 clang/test/SemaTemplate/temp_func_order.cpp (limited to 'clang/test/SemaTemplate/temp_func_order.cpp') diff --git a/clang/test/SemaTemplate/temp_func_order.cpp b/clang/test/SemaTemplate/temp_func_order.cpp new file mode 100644 index 0000000..908354b --- /dev/null +++ b/clang/test/SemaTemplate/temp_func_order.cpp @@ -0,0 +1,95 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +template +int &f0(T); + +template +float &f0(T*); + +void test_f0(int i, int *ip) { + int &ir = f0(i); + float &fr = f0(ip); +} + +template +int &f1(T, U); + +template +float &f1(T, T); + +void test_f1(int i, float f) { + int &ir = f1(i, f); + float &fr1 = f1(i, i); + float &fr2 = f1(f, f); +} + +template +struct A { }; + +template +int &f2(T); + +template +float &f2(A); + +template +double &f2(A); + +void test_f2(int i, A aif, A aii) { + int &ir = f2(i); + float &fr = f2(aif); + double &dr = f2(aii); +} + +template +int &f3(T*, U); // expected-note{{candidate}} + +template +float &f3(T, U*); // expected-note{{candidate}} + +void test_f3(int i, int *ip, float *fp) { + int &ir = f3(ip, i); + float &fr = f3(i, fp); + f3(ip, ip); // expected-error{{ambiguous}} +} + +template +int &f4(T&); + +template +float &f4(const T&); + +void test_f4(int i, const int ic) { + int &ir1 = f4(i); + float &fr1 = f4(ic); +} + +template +int &f5(T&, const U&); // expected-note{{candidate}} + +template +float &f5(const T&, U&); // expected-note{{candidate}} + +void test_f5(int i, const int ic) { + f5(i, i); // expected-error{{ambiguous}} +} + +template +int &f6(T&, U&); + +template +float &f6(const T&, U&); + +void test_f6(int i, const int ic) { + int &ir = f6(i, i); + float &fr = f6(ic, ic); +} + +struct CrazyFun { + template operator A(); + template operator A(); +}; + +void fun(CrazyFun cf) { + A aif = cf; + A aii = cf; +} -- cgit v1.2.3