================
@@ -13093,12 +13094,16 @@ static bool isSameWidthConstantConversion(Sema &S, 
Expr *E, QualType T,
       return false;
   }
 
-  // If the CC location points to a '{', and the type is char, then assume
-  // assume it is an array initialization.
+  // If the CC location points to a '{', and the destination type is char or
+  // unsigned char, then assume this is an array initialization. Keep warning
+  // for signed char arrays, where values such as 255 change sign.
   if (CC.isValid() && T->isCharType()) {
+    const auto *BT =
+        dyn_cast<BuiltinType>(S.Context.getCanonicalType(T).getTypePtr());
     const char FirstContextCharacter =
         S.getSourceManager().getCharacterData(CC)[0];
-    if (FirstContextCharacter == '{')
+    if (BT && BT->getKind() != BuiltinType::SChar &&
----------------
AaronBallman wrote:

I think we need a test for `-fsigned-char`/`-fno-signed-char` and using `char` 
as that's also currently not working correctly: https://godbolt.org/z/fs5GhvEq3

https://github.com/llvm/llvm-project/pull/203792
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to