[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:53:02 PDT 2022


yonghong-song added inline comments.


================
Comment at: clang/lib/Sema/SemaDecl.cpp:2033
     return;
+
   unsigned DiagID = isa<ParmVarDecl>(VD) ? diag::warn_unused_but_set_parameter
----------------
efriedma wrote:
> (Accidental change?)
Right. Thanks for catching this. This is a leftover from my previous debugging code and forgot to remove it.


================
Comment at: clang/lib/Sema/SemaExprCXX.cpp:7925
   DeclRefExpr *LHS = nullptr;
+  bool IsComponentAssign = false;
   if (BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
----------------
aaron.ballman wrote:
> 
Thanks, really embarrassing typo. 


================
Comment at: clang/test/Sema/warn-unused-but-set-variables.c:35
+  // volatile variable k is used, no warning.
+  volatile int k = 0;
+  for (int i = 0; i < 1000; i++)
----------------
aaron.ballman wrote:
> I'd like to see another test:
> ```
> typedef volatile int volint;
> volint l = 0;
> l += 1; // no warning
> ```
Will do.


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