[clang] [clang] Check `std::initializer_list` more strictly (PR #133822)

Yanzuo Liu via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 31 19:19:48 PDT 2025


================
@@ -2590,8 +2590,14 @@ def err_auto_non_deduced_not_alone : Error<
 def err_implied_std_initializer_list_not_found : Error<
   "cannot deduce type of initializer list because std::initializer_list was "
   "not found; include <initializer_list>">;
-def err_malformed_std_initializer_list : Error<
-  "std::initializer_list must be a class template with a single type parameter">;
+def err_malformed_std_initializer_list
+    : Error<"std::initializer_list %select{"
+            "must have exactly one template parameter|"
+            "cannot have associated constraints|"
+            "must have a type template parameter|"
+            "cannot have default template arguments|"
+            "cannot be a variadic template|"
+            "must be a class template}0">;
----------------
zwuis wrote:

Can you use "enum_select" format instead of "select" format?

See <https://clang.llvm.org/docs/InternalsManual.html#formatting-a-diagnostic-argument>.

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


More information about the cfe-commits mailing list