[clang] [Clang] Separate implicit int conversion on negation sign to new diagnostic group (PR #139429)

via cfe-commits cfe-commits at lists.llvm.org
Fri May 16 02:52:42 PDT 2025


================
@@ -12091,6 +12091,11 @@ void Sema::CheckImplicitConversion(Expr *E, QualType T, SourceLocation CC,
     if (SourceMgr.isInSystemMacro(CC))
       return;
 
+    if (const auto *UO = dyn_cast<UnaryOperator>(E)) {
+      return DiagnoseImpCast(*this, E, T, CC,
+                             diag::warn_impcast_integer_precision_on_negation);
+    }
+
----------------
cor3ntin wrote:

We should check which operator it is. Did you try to add tests with 

```
unsigned char test_diag(unsigned char x) {
    return +x;
}```


https://github.com/llvm/llvm-project/pull/139429


More information about the cfe-commits mailing list