diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-11-13 18:44:21 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-11-13 18:44:21 +0000 |
commit | 379d84b7ed24980a3dbd3d60e4ab2bacce290c0c (patch) | |
tree | 7a05374f27c08e4419a4167ba3ffdd9017488c00 /clang/test | |
parent | 07eae02fc7252d4f7c13aac82be47d650b3057bf (diff) | |
download | bcm5719-llvm-379d84b7ed24980a3dbd3d60e4ab2bacce290c0c.tar.gz bcm5719-llvm-379d84b7ed24980a3dbd3d60e4ab2bacce290c0c.zip |
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.
llvm-svn: 88670
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/SemaCXX/conversion-function.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/clang/test/SemaCXX/conversion-function.cpp b/clang/test/SemaCXX/conversion-function.cpp index 6182678e311..c0c318ed336 100644 --- a/clang/test/SemaCXX/conversion-function.cpp +++ b/clang/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(); +} + + |