Fixing warning C4189 in SemaTemplateDeduction.cpp

Yaron Keren yaron.keren at gmail.com
Wed May 13 11:00:55 PDT 2015


Committed revision 237267, thanks!


2015-05-13 19:54 GMT+03:00 Aaron Ballman <aaron at aaronballman.com>:

> On Wed, May 13, 2015 at 12:42 PM, Yaron Keren <yaron.keren at gmail.com>
> wrote:
> > Hi Aaron,
> >
> > What do you think about fixing:
> >
> > tools\clang\lib\Sema\SemaTemplateDeduction.cpp(3660): warning C4189:
> > 'Result' : local variable is initialize d but not referenced
> >
> > with
> >
> > Index: tools/clang/lib/Sema/SemaTemplateDeduction.cpp
> > ===================================================================
> > --- tools/clang/lib/Sema/SemaTemplateDeduction.cpp      (revision 237261)
> > +++ tools/clang/lib/Sema/SemaTemplateDeduction.cpp      (working copy)
> > @@ -3656,8 +3656,10 @@
> >    FunctionTemplateDecl *InvokerTemplate = LambdaClass->
> >
> getLambdaStaticInvoker()->getDescribedFunctionTemplate();
> >
> > -  Sema::TemplateDeductionResult LLVM_ATTRIBUTE_UNUSED Result
> > -    = S.FinishTemplateArgumentDeduction(InvokerTemplate,
> DeducedArguments,
> > 0,
> > +#ifndef NDEBUG
> > +  Sema::TemplateDeductionResult LLVM_ATTRIBUTE_UNUSED Result =
> > +#endif
> > +    S.FinishTemplateArgumentDeduction(InvokerTemplate,
> DeducedArguments, 0,
> >            InvokerSpecialized, TDInfo);
> >    assert(Result == Sema::TDK_Success &&
> >      "If the call operator succeeded so should the invoker!");
> >
> >
> > The problem is LLVM_ATTRIBUTE_UNUSED does not work with Visual C++.
>
> Yoiks. That's likely the best way to solve it, short of disabling the
> warning entirely (which I'd still be opposed to, but less so having
> seen this code).
>
> ~Aaron
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150513/49dd38b8/attachment.html>


More information about the cfe-commits mailing list