summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/conversion-function.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-08-11 02:15:33 +0000
committerDouglas Gregor <dgregor@apple.com>2010-08-11 02:15:33 +0000
commit836a7e8468a76320bbdce9752b7d4aef9b5afdf2 (patch)
tree138e2af979b149d81aef5f3c402d40a2b27dfedd /clang/test/SemaCXX/conversion-function.cpp
parent8c9c9c77c8f51b5b2eb85d0ad1b4192a7d765c95 (diff)
downloadbcm5719-llvm-836a7e8468a76320bbdce9752b7d4aef9b5afdf2.tar.gz
bcm5719-llvm-836a7e8468a76320bbdce9752b7d4aef9b5afdf2.zip
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. llvm-svn: 110773
Diffstat (limited to 'clang/test/SemaCXX/conversion-function.cpp')
-rw-r--r--clang/test/SemaCXX/conversion-function.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/conversion-function.cpp b/clang/test/SemaCXX/conversion-function.cpp
index d7d41a40311..73b78f414a5 100644
--- a/clang/test/SemaCXX/conversion-function.cpp
+++ b/clang/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());
+}
OpenPOWER on IntegriCloud