diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-08-11 02:15:33 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-08-11 02:15:33 +0000 |
commit | 604eb65686590f73551d4ea608b174d2244cdd0f (patch) | |
tree | 9bff98f1b559d0ed8672c390ae73e3368fe6166b /test/SemaCXX/conversion-function.cpp | |
parent | 7fc3702694996d7d373e3280812a4172cf451aac (diff) |
Improve our handling of user-defined conversions when computing
implicit conversion sequences. In particular, model the "standard
conversion" from a class to its own type (or a base type) directly as
a standard conversion in the normal path *without* trying to determine
if there is a valid copy constructor. This appears to match the intent
of C++ [over.best.ics]p6 and more closely matches GCC and EDG.
As part of this, model non-lvalue reference initialization via
user-defined conversion in overloading the same way we handle it in
InitializationSequence, separating the "general user-defined
conversion" and "conversion to compatible class type" cases.
The churn in the overload-call-copycon.cpp test case is because the
test case was originally wrong; it assumed that we should do more
checking for copy constructors that we actually should, which affected
overload resolution.
Fixes PR7055. Bootstrapped okay.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110773 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/conversion-function.cpp')
-rw-r--r-- | test/SemaCXX/conversion-function.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/SemaCXX/conversion-function.cpp b/test/SemaCXX/conversion-function.cpp index d7d41a4031..73b78f414a 100644 --- a/test/SemaCXX/conversion-function.cpp +++ b/test/SemaCXX/conversion-function.cpp @@ -214,3 +214,37 @@ struct Other { void test_any() { Any any = Other(); // expected-error{{cannot pass object of non-POD type 'Other' through variadic constructor; call will abort at runtime}} } + +namespace PR7055 { + // Make sure that we don't allow too many conversions in an + // auto_ptr-like template. In particular, we can't create multiple + // temporary objects when binding to a reference. + struct auto_ptr { + struct auto_ptr_ref { }; + + auto_ptr(auto_ptr&); + auto_ptr(auto_ptr_ref); + explicit auto_ptr(int *); + + operator auto_ptr_ref(); + }; + + struct X { + X(auto_ptr); + }; + + X f() { + X x(auto_ptr(new int)); + return X(auto_ptr(new int)); + } + + auto_ptr foo(); + + X e(foo()); + + struct Y { + Y(X); + }; + + Y f2(foo()); +} |