Fixing warning C4189 in SemaTemplateDeduction.cpp

Aaron Ballman aaron at aaronballman.com
Wed May 13 09:54:44 PDT 2015


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



More information about the cfe-commits mailing list