[clang] [Clang] enhance diagnostic message for __builtin_bit_cast size mismatch (PR #115940)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 13 05:28:27 PST 2024


================
@@ -12354,7 +12354,8 @@ def err_preserve_enum_value_not_const: Error<
 def err_bit_cast_non_trivially_copyable : Error<
   "__builtin_bit_cast %select{source|destination}0 type must be trivially copyable">;
 def err_bit_cast_type_size_mismatch : Error<
-  "__builtin_bit_cast source size does not equal destination size (%0 vs %1)">;
+  "__builtin_bit_cast source type %0 size (%1 %plural{1:byte|:bytes}1) "
+  "does not match destination type %2 size (%3 %plural{1:byte|:bytes}3)">;
----------------
AaronBallman wrote:

How about:
`size of '__builtin_bit_cast' source type %0 does not match destination type %1 (%2 vs %3 bytes)`
mostly because it's slightly more succinct?

(Btw, we should fix the other diagnostics to also put single quotes around `__builtin_bit_cast` -- we generally put single quotes around syntactic constructs in diagnostic messages. That's an NFC change for another patch though.)

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


More information about the cfe-commits mailing list