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)
commit7c2bcc9eb038df5fa238276749a88f289e9861ae
treefec04fe63bc882c0526a4301ac9fede9009c8656
parentc1d527d3d832cac86eb9461dcef978011ef8caeb
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.

llvm-svn: 280776
clang/lib/Sema/SemaInit.cpp
clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp
clang/test/CXX/drs/dr0xx.cpp
clang/test/CXX/drs/dr1xx.cpp
clang/test/CodeGenCXX/copy-constructor-elim-2.cpp
clang/test/SemaCXX/conditional-expr.cpp
clang/test/SemaCXX/copy-initialization.cpp
clang/test/SemaCXX/cxx0x-initializer-constructor.cpp
clang/test/SemaCXX/cxx11-inheriting-ctors.cpp
clang/test/SemaCXX/cxx98-compat-flags.cpp
clang/test/SemaCXX/cxx98-compat-pedantic.cpp