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). --- .../temp.deduct/temp.deduct.call/p3-0x.cpp | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3-0x.cpp (limited to 'clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3-0x.cpp') diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3-0x.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3-0x.cpp new file mode 100644 index 0000000..e470dd0 --- /dev/null +++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3-0x.cpp @@ -0,0 +1,46 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s + + +// If P is an rvalue reference to a cv-unqualified template parameter +// and the argument is an lvalue, the type "lvalue reference to A" is +// used in place of A for type deduction. +template struct X { }; + +template X f0(T&&); + +struct Y { }; + +template T prvalue(); +template T&& xvalue(); +template T& lvalue(); + +void test_f0() { + X xi0 = f0(prvalue()); + X xi1 = f0(xvalue()); + X xi2 = f0(lvalue()); + X xy0 = f0(prvalue()); + X xy1 = f0(xvalue()); + X xy2 = f0(lvalue()); +} + +template X f1(const T&&); // expected-note{{candidate function [with T = int] not viable: no known conversion from 'int' to 'const int &&' for 1st argument}} \ +// expected-note{{candidate function [with T = Y] not viable: no known conversion from 'Y' to 'const Y &&' for 1st argument}} + +void test_f1() { + X xi0 = f1(prvalue()); + X xi1 = f1(xvalue()); + f1(lvalue()); // expected-error{{no matching function for call to 'f1'}} + X xy0 = f1(prvalue()); + X xy1 = f1(xvalue()); + f1(lvalue()); // expected-error{{no matching function for call to 'f1'}} +} + +namespace std_example { + template int f(T&&); + template int g(const T&&); // expected-note{{candidate function [with T = int] not viable: no known conversion from 'int' to 'const int &&' for 1st argument}} + + int i; + int n1 = f(i); + int n2 = f(0); + int n3 = g(i); // expected-error{{no matching function for call to 'g'}} +} -- cgit v1.2.3