diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-11-01 01:37:11 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-11-01 01:37:11 +0000 |
commit | 2680fb2e8a862140ca2ad728276eeea9bfb1d103 (patch) | |
tree | 27569a25d1ae66683fe5d8362bcab3b639fedf21 /test/SemaCXX | |
parent | eb1c10e34de92b9ee0d0ccfbef13a231187eda3d (diff) |
[c++17] Refine resolution of constructor / conversion function disambiguation.
Given a choice between a constructor call and a conversion function in C++17,
we prefer the constructor for direct-initialization and the conversion function
for copy-initialization, matching the behavior in C++14 and before. The
guaranteed copy elision rules were not intended to change the meaning of such
code (other than by removing unnecessary copy constructor calls).
This tweak will be raised with CWG.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@317066 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX')
-rw-r--r-- | test/SemaCXX/cxx1z-copy-omission.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/SemaCXX/cxx1z-copy-omission.cpp b/test/SemaCXX/cxx1z-copy-omission.cpp index cba6bc3be3..a7133d79b4 100644 --- a/test/SemaCXX/cxx1z-copy-omission.cpp +++ b/test/SemaCXX/cxx1z-copy-omission.cpp @@ -160,3 +160,12 @@ struct AsDelegating final { // classes? AsDelegating(int n) : AsDelegating(make(n)) {} // expected-error {{deleted}} }; + +namespace CtorTemplateBeatsNonTemplateConversionFn { + struct Foo { template <typename Derived> Foo(const Derived &); }; + template <typename Derived> struct Base { operator Foo() const = delete; }; // expected-note {{deleted}} + struct Derived : Base<Derived> {}; + + Foo f(Derived d) { return d; } // expected-error {{invokes a deleted function}} + Foo g(Derived d) { return Foo(d); } // ok, calls constructor +} |