diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-01-24 16:14:37 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-01-24 16:14:37 +0000 |
commit | 8dde14e7f43a4b29e592b3e8e576eb467ddb6c6e (patch) | |
tree | 926ec6608ecc240a7101b0f595d33840afb6f75f /test | |
parent | 274f83c2ece9041a1994fc3eacfe812ca86095e8 (diff) |
Re-instate r123977/r123978, my updates of the reference-binding
implementation used by overload resolution to support rvalue
references. The original commits caused PR9026 and some
hard-to-reproduce self-host breakage.
The only (crucial!) difference between this commit and the previous
commits is that we now properly check the SuppressUserConversions flag
before attempting to perform a second user-defined conversion in
reference binding, breaking the infinite recursion chain of
user-defined conversions.
Rvalue references should be working a bit better now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124121 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp | 34 | ||||
-rw-r--r-- | test/SemaCXX/conditional-expr.cpp | 5 | ||||
-rw-r--r-- | test/SemaCXX/decl-init-ref.cpp | 2 |
3 files changed, 38 insertions, 3 deletions
diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp index 6f81326b1d..7b0fb9c52b 100644 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp @@ -17,7 +17,7 @@ int f(int); template<typename T> struct ConvertsTo { - operator T(); // expected-note 2{{candidate function}} + operator T(); // expected-note 4{{candidate function}} }; void test_rvalue_refs() { @@ -130,3 +130,35 @@ namespace std_example_2 { double&& rrd3 = i; } +namespace argument_passing { + void base_rvalue_ref(Base&&); + void int_rvalue_ref(int&&); // expected-note 2{{passing argument to parameter here}} + void array_rvalue_ref(int (&&)[5]); + void function_rvalue_ref(int (&&)(int)); + + void test() { + base_rvalue_ref(xvalue<Base>()); + base_rvalue_ref(xvalue<Derived>()); + int_rvalue_ref(xvalue<int>()); + + base_rvalue_ref(prvalue<Base>()); + base_rvalue_ref(prvalue<Derived>()); + + array_rvalue_ref(HasArray().array); + + function_rvalue_ref(f); + + base_rvalue_ref(ConvertsTo<Base&&>()); + base_rvalue_ref(ConvertsTo<Derived&&>()); + int_rvalue_ref(ConvertsTo<int&&>()); + + base_rvalue_ref(ConvertsTo<Base>()); + base_rvalue_ref(ConvertsTo<Derived>()); + + function_rvalue_ref(ConvertsTo<int(&)(int)>()); + + int_rvalue_ref(ConvertsTo<int&>()); // expected-error{{no viable conversion from 'ConvertsTo<int &>' to 'int'}} + int_rvalue_ref(ConvertsTo<float&>()); // expected-error{{no viable conversion from 'ConvertsTo<float &>' to 'int'}} + } + +} diff --git a/test/SemaCXX/conditional-expr.cpp b/test/SemaCXX/conditional-expr.cpp index a7f2a4c915..8ac0a9736a 100644 --- a/test/SemaCXX/conditional-expr.cpp +++ b/test/SemaCXX/conditional-expr.cpp @@ -7,7 +7,10 @@ struct ToBool { explicit operator bool(); }; struct B; -struct A { A(); A(const B&); }; // expected-note 2 {{candidate constructor}} +struct A { + A(); + A(const B&); // expected-note 2 {{candidate constructor}} +}; struct B { operator A() const; }; // expected-note 2 {{candidate function}} struct I { operator int(); }; struct J { operator I(); }; diff --git a/test/SemaCXX/decl-init-ref.cpp b/test/SemaCXX/decl-init-ref.cpp index dc56332b5d..34c4578e9d 100644 --- a/test/SemaCXX/decl-init-ref.cpp +++ b/test/SemaCXX/decl-init-ref.cpp @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s -struct A {}; // expected-note {{candidate is the implicit copy constructor}} +struct A {}; struct BASE { operator A(); // expected-note {{candidate function}} |