[PATCH] D130058: [Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 26 12:38:40 PDT 2022


aaron.ballman added inline comments.


================
Comment at: clang/include/clang/Basic/DiagnosticASTKinds.td:370
+def note_constexpr_unscoped_enum_out_of_range : Note<
+  "store of value outside of the range of unscoped enum, valid values %0 to %1">;
 def err_experimental_clang_interp_failed : Error<
----------------
How about: `integer value %0 is outside the valid range of values [%1, %2) for this enumeration type`

This also would nicely handle the case where the value comes as a result of a complex constant expression or constexpr function call, etc and isn't immediately obvious to the reader.


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

https://reviews.llvm.org/D130058



More information about the cfe-commits mailing list