[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
Tue Mar 15 19:24:39 PDT 2022


yonghong-song added inline comments.


================
Comment at: clang/test/Sema/warn-unused-but-set-variables.c:66
+  for (int i = 0; i < 1000; i++)
+    j += 1;
+  return;
----------------
efriedma wrote:
> The handling of this testcase without your patch seems fine.  Even if the value of j is technically read, it's not "used" in any meaningful way.
> 
> I think the distinguishing factor for the testcase we discussed before is the use of a "volatile".  Volatile is rare, and indicates the user is intentionally doing something unusual, so it probably doesn't make sense to warn.
@eli.friedman Just updated the patch to handle volatile variable only.


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