[PATCH] D141283: [clang] Improve diagnostic for "initializer-string for char array is too long"

Shafik Yaghmour via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 9 07:41:15 PST 2023


shafik added a comment.

Thank you for this diagnostic fix, please make sure you update `clang/test/CXX/dcl.decl/dcl.init/dcl.init.string/p2.cpp`.



================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:5956
 def err_initializer_string_for_char_array_too_long : Error<
-  "initializer-string for char array is too long">;
+  "initializer-string for char array is too long, expected %0 but was %1 (including the null terminating character)">;
 def ext_initializer_string_for_char_array_too_long : ExtWarn<
----------------
Note. we are allowed to initialize with a string-literal that is smaller than the array size so maybe something along the lines of `array size is %0 but initializer has size %1`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141283



More information about the cfe-commits mailing list