[PATCH] D139114: [Clang][Sema] Enabled Wshorten-64-to-32 for CompoundAssignment operator.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 3 09:09:11 PST 2023


aaron.ballman added a reviewer: libc++.
aaron.ballman added a comment.

It looks like this change breaks libc++ (see the precommit CI failures) by making more changes than expected. I'm now seeing `implicit conversion changes signedness` diagnostics where we didn't previously get them. Is that expected and intentional? (I think it may be a fix: https://godbolt.org/z/hTaaf8c5P so I'm adding the libc++ folks just in case they disagree.)

Also, these changes should come with an entry in the release notes.



================
Comment at: clang/lib/Sema/SemaChecking.cpp:13400-13401
 
+  // Check for implicit conversion loss of precision form 64-to-32 for compound
+  // statements.
+  if (E->getLHS()->getType()->isIntegerType() &&
----------------
This comment isn't quite accurate, right? It's checking for any kind of implicit conversion issue (such as changing signs even if the integer widths stay the same).


================
Comment at: clang/test/Sema/conversion-64-32.c:22
+// rdar://10466193
+void test3(int i, long long ll) {
+  i += ll; // expected-warning {{implicit conversion loses integer precision}}
----------------
Can you also add tests for the shift assign behavior, since that's being handled in a special way?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139114



More information about the cfe-commits mailing list