aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-11-13 18:44:21 +0000
committerDouglas Gregor <dgregor@apple.com>2009-11-13 18:44:21 +0000
commit79b680ea869983d62b84a9175eeb6b6efb376326 (patch)
tree89057c43da06cb790e38a6f290d0aba93363e3a8 /test
parentafe7ec28b1880335daba5f7310fe5191e14c4e76 (diff)
When performing copy initialization (= "implicit conversion", here) to
a class type from itself or a derived class thereof, enumerate constructors and permit user-defined conversions to the arguments of those constructors. This fixes the wacky implicit conversion sequence used in std::auto_ptr's lame emulation of move semantics. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88670 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/SemaCXX/conversion-function.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/test/SemaCXX/conversion-function.cpp b/test/SemaCXX/conversion-function.cpp
index 6182678e31..c0c318ed33 100644
--- a/test/SemaCXX/conversion-function.cpp
+++ b/test/SemaCXX/conversion-function.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-cc -fsyntax-only -verify %s
+// RUN: clang-cc -fsyntax-only -verify %s
class X {
public:
operator bool();
@@ -93,3 +93,31 @@ void f(Yb& a) {
char ch = a; // OK. calls Yb::operator char();
}
+// Test conversion + copy construction.
+class AutoPtrRef { };
+
+class AutoPtr {
+ // FIXME: Using 'unavailable' since we do not have access control yet.
+ // FIXME: The error message isn't so good.
+ AutoPtr(AutoPtr &) __attribute__((unavailable));
+
+public:
+ AutoPtr();
+ AutoPtr(AutoPtrRef);
+
+ operator AutoPtrRef();
+};
+
+AutoPtr make_auto_ptr();
+
+AutoPtr test_auto_ptr(bool Cond) {
+ AutoPtr p1( make_auto_ptr() );
+
+ AutoPtr p;
+ if (Cond)
+ return p; // expected-error{{incompatible type returning}}
+
+ return AutoPtr();
+}
+
+