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

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 15 10:14:01 PDT 2022


efriedma 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;
----------------
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.


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