Fix deduction for conversion function templates converting to reference
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 11 Jul 2018 23:19:41 +0000 (23:19 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 11 Jul 2018 23:19:41 +0000 (23:19 +0000)
commitb884ed186eb705c4c5b5ebfcc864f3cfc8794bbb
tree29b2a3a1912a6b617c7ecc3992da8572c579322e
parentdc7200b486b6c5b5229abcee97c160145cc3d955
Fix deduction for conversion function templates converting to reference
types.

We previously tried to use the "parameter is a reference" logic here,
but that doesn't work because it gets P and A backwards. Instead, add
a separate implementation of the "deduced A can be less qualified than
A" rule.

This also exposes that we incorrectly stripped cv-qualifiers from the
referent of A if it was a reference. However, if we don't do that, we
get the wrong results when P is a reference. In an attempt to match
what sanity dictates and what other implementations are doing, we now
remove cv-qualifiers from A and P unless both are reference types. I've
brought this up on the core reflector too, to try to get the standard
fixed.

llvm-svn: 336867
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p4.cpp