This patch adds a note to help users unfamiliar with modules terminology
understand how to declare main in a named module since P3618.
There doesn't appear to be an easy robust location available for "the
start of this declaration" that I could find to attach a fixit to, but
the explanation should suffice.
gcc/cp/ChangeLog:
* decl.cc (grokfndecl): Add explanation of how to attach to
global module.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
pedwarn (location, OPT_Wpedantic, "cannot declare %<::main%> with a"
" linkage specification other than %<extern \"C++\"%>");
if (module_attach_p ())
- error_at (location, "cannot attach %<::main%> to a named module");
+ {
+ auto_diagnostic_group adg;
+ error_at (location, "cannot attach %<::main%> to a named module");
+ inform (location, "use %<extern \"C++\"%> to attach it to the "
+ "global module instead");
+ }
inlinep = 0;
publicp = 1;
}