[cfe-commits] r133237 - /cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp

Francois Pichet pichet2000 at gmail.com
Sun Jun 19 19:46:20 PDT 2011


On Fri, Jun 17, 2011 at 11:36 AM, Argyrios Kyrtzidis
<kyrtzidis at apple.com> wrote:
> On Jun 17, 2011, at 7:42 AM, Douglas Gregor wrote:
>
>>
>> On Jun 17, 2011, at 6:11 AM, Francois Pichet wrote:
>>
>>> On Fri, Jun 17, 2011 at 1:18 AM, Douglas Gregor <dgregor at apple.com> wrote:
>>>> Author: dgregor
>>>> Date: Fri Jun 17 00:18:17 2011
>>>> New Revision: 133237
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=133237&view=rev
>>>> Log:
>>>> Factor the checking of the deduced argument type against the actual
>>>> argument type for C++ [temp.deduct.call]p4 out of
>>>> Sema::FinishTemplateArgumentDeduction(). No functionality change.
>>>>
>>>>
>>>> Modified:
>>>>   cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
>>>>
>>>> Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
>>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=133237&r1=133236&r2=133237&view=diff
>>>> ==============================================================================
>>>> /// \brief Finish template argument deduction for a function template,
>>>> /// checking the deduced template arguments for completeness and forming
>>>> /// the function template specialization.
>>>> @@ -2487,85 +2569,14 @@
>>>>    //   is transformed as described above). [...]
>>>>    for (unsigned I = 0, N = OriginalCallArgs->size(); I != N; ++I) {
>>>>      OriginalCallArg OriginalArg = (*OriginalCallArgs)[I];
>>>> -      QualType A = OriginalArg.OriginalArgType;
>>>>      unsigned ParamIdx = OriginalArg.ArgIdx;
>>>>
>>>>      if (ParamIdx >= Specialization->getNumParams())
>>>>        continue;
>>>>
>>>>      QualType DeducedA = Specialization->getParamDecl(ParamIdx)->getType();
>>>> -      QualType OriginalParamType = OriginalArg.OriginalParamType;
>>>> -
>>>> -      // Check for type equality (top-level cv-qualifiers are ignored).
>>>> -      if (Context.hasSameUnqualifiedType(A, DeducedA))
>>>> -        continue;
>>>> -
>>>> -      // Strip off references on the argument types; they aren't needed for
>>>> -      // the following checks.
>>>> -      if (const ReferenceType *DeducedARef = DeducedA->getAs<ReferenceType>())
>>>> -        DeducedA = DeducedARef->getPointeeType();
>>>> -      if (const ReferenceType *ARef = A->getAs<ReferenceType>())
>>>> -        A = ARef->getPointeeType();
>>>> -
>>>> -      // C++ [temp.deduct.call]p4:
>>>> -      //   [...] However, there are three cases that allow a difference:
>>>> -      //     - If the original P is a reference type, the deduced A (i.e., the
>>>> -      //       type referred to by the reference) can be more cv-qualified than
>>>> -      //       the transformed A.
>>>> -      if (const ReferenceType *OriginalParamRef
>>>> -                                  = OriginalParamType->getAs<ReferenceType>()) {
>>>> -        // We don't want to keep the reference around any more.
>>>> -        OriginalParamType = OriginalParamRef->getPointeeType();
>>>> -
>>>> -        Qualifiers AQuals = A.getQualifiers();
>>>> -        Qualifiers DeducedAQuals = DeducedA.getQualifiers();
>>>> -        if (AQuals == DeducedAQuals) {
>>>> -          // Qualifiers match; there's nothing to do.
>>>> -        } else if (!DeducedAQuals.compatiblyIncludes(AQuals)) {
>>>> -          return Sema::TDK_SubstitutionFailure;
>>>
>>> why not return true here?
>>> Otherwise it warns under MSVC with suspicious conversion to bool
>>
>> Oops! It was a refactoro, fixed in r133257. Thanks!
>
> Looks like the warning was useful. Francois, could you please file a bug report with a test case so that we implement the warning in clang as well ?
>

ok here it is:
http://llvm.org/bugs/show_bug.cgi?id=10159




More information about the cfe-commits mailing list