[PATCH] D121715: [Clang] Fix an unused-but-set-variable warning with volatile variable

Yonghong Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 21 12:55:52 PDT 2022


yonghong-song added a comment.

In D121715#3397407 <https://reviews.llvm.org/D121715#3397407>, @efriedma wrote:

> In D121715#3397215 <https://reviews.llvm.org/D121715#3397215>, @xbolva00 wrote:
>
>> If there is j = j + 1 .. do we warn ?
>
>
>
> In D121715#3397237 <https://reviews.llvm.org/D121715#3397237>, @xbolva00 wrote:
>
>>   j++;
>>
>> Should not we warn in this case? (Currently no warning)
>
> We probably should warn in both those cases; the variable clearly isn't "used" in any meaningful way.

The 'j++' is not warned as it is not a BinaryOperator or CXXOperatorCallExpr so it is not handled and considered no warning by default.
This patch intends to handle volatile variables. We can have another patch to deal with this specific case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121715/new/

https://reviews.llvm.org/D121715



More information about the cfe-commits mailing list