Fix clang's handling of the copy performed in the second phase of class
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 7 Sep 2016 02:14:33 +0000 (02:14 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 7 Sep 2016 02:14:33 +0000 (02:14 +0000)
commit0d385d2fc4bde120efd24cbc0c3a4abeb58fa872
tree4702d457217239fb38dce51d8c6034d1056147da
parent5fbaf12bf717d2ff470c8ae03e642cc04a8f1a4e
Fix clang's handling of the copy performed in the second phase of class
copy-initialization. We previously got this wrong in a couple of ways:
 - we only looked for copy / move constructors and constructor templates for
   this copy, and thus would fail to copy in cases where doing so should use
   some other constructor (but see core issue 670),
 - we mishandled the special case for disabling user-defined conversions that
   blocks infinite recursion through repeated application of a copy constructor
   (applying it in slightly too many cases) -- though as far as I can tell,
   this does not ever actually affect the result of overload resolution, and
 - we misapplied the special-case rules for constructors taking a parameter
   whose type is a (reference to) the same class type by incorrectly assuming
   that only happens for copy/move constructors (it also happens for
   constructors instantiated from templates and those inherited from base
   classes).

These changes should only affect strange corner cases (for instance, where the
copy constructor exists but has a non-const-qualified parameter type), so for
the most part it only causes us to produce more 'candidate' notes, but see the
test changes for other cases whose behavior is affected.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@280776 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Sema/SemaInit.cpp
test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp
test/CXX/drs/dr0xx.cpp
test/CXX/drs/dr1xx.cpp
test/CodeGenCXX/copy-constructor-elim-2.cpp
test/SemaCXX/conditional-expr.cpp
test/SemaCXX/copy-initialization.cpp
test/SemaCXX/cxx0x-initializer-constructor.cpp
test/SemaCXX/cxx11-inheriting-ctors.cpp
test/SemaCXX/cxx98-compat-flags.cpp
test/SemaCXX/cxx98-compat-pedantic.cpp