diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-04-17 22:01:05 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-04-17 22:01:05 +0000 |
| commit | 5ab116553171e67015f63178a3927de22400e3da (patch) | |
| tree | 783c4344096e148c8bcfb1303c6b1987ccb48c44 /clang/test/SemaCXX/conversion-function.cpp | |
| parent | 8345a70c671dbd5d7dcfbd1e0e1f68fc9ed0e0c6 (diff) | |
| download | bcm5719-llvm-5ab116553171e67015f63178a3927de22400e3da.tar.gz bcm5719-llvm-5ab116553171e67015f63178a3927de22400e3da.zip | |
Improve our handling of user-defined conversions as part of overload
resolution. There are two sources of problems involving user-defined
conversions that this change eliminates, along with providing simpler
interfaces for checking implicit conversions:
- It eliminates a case of infinite recursion found in Boost.
- It eliminates the search for the constructor needed to copy a temporary
generated by an implicit conversion from overload
resolution. Overload resolution assumes that, if it gets a value
of the parameter's class type (or a derived class thereof), there
is a way to copy if... even if there isn't. We now model this
properly.
llvm-svn: 101680
Diffstat (limited to 'clang/test/SemaCXX/conversion-function.cpp')
| -rw-r--r-- | clang/test/SemaCXX/conversion-function.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/clang/test/SemaCXX/conversion-function.cpp b/clang/test/SemaCXX/conversion-function.cpp index 972409ca5a3..dfc06506419 100644 --- a/clang/test/SemaCXX/conversion-function.cpp +++ b/clang/test/SemaCXX/conversion-function.cpp @@ -129,7 +129,7 @@ private: }; A1 f() { - return "Hello"; // expected-error{{invokes deleted copy constructor}} + return "Hello"; // expected-error{{invokes deleted constructor}} } namespace source_locations { @@ -176,3 +176,29 @@ namespace crazy_declarators { *operator int(); // expected-error {{must use a typedef to declare a conversion to 'int *'}} }; } + +namespace smart_ptr { + class Y { + class YRef { }; + + Y(Y&); + + public: + Y(); + Y(YRef); + + operator YRef(); // expected-note{{candidate function}} + }; + + struct X { // expected-note{{candidate constructor (the implicit copy constructor) not}} + explicit X(Y); + }; + + Y make_Y(); + + X f() { + X x = make_Y(); // expected-error{{no viable conversion from 'smart_ptr::Y' to 'smart_ptr::X'}} + X x2(make_Y()); + return X(Y()); + } +} |

