[clang] [clang] [modules] Add err_main_in_named_module (PR #146635)

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 2 00:03:49 PDT 2025


================
@@ -1062,6 +1062,10 @@ def err_constexpr_main : Error<
   "'main' is not allowed to be declared %select{constexpr|consteval}0">;
 def err_deleted_main : Error<"'main' is not allowed to be deleted">;
 def err_mainlike_template_decl : Error<"%0 cannot be a template">;
+def warn_main_in_named_module
+    : ExtWarn<"'main' should not be attached to a named module; consider "
+              "adding C++ language linkage">,
----------------
cor3ntin wrote:

Maybe just `'main' never has module linkage;" the "Consider..." is somewhat redundant with the fixit

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


More information about the cfe-commits mailing list