if (cxx_dialect >= cxx17 && type && is_auto (type)
&& innermost_code != cdk_function
+ /* Placeholder in parm gets a better error below. */
+ && !(decl_context == PARM || decl_context == CATCHPARM)
&& id_declarator && declarator != id_declarator)
if (tree tmpl = CLASS_PLACEHOLDER_TEMPLATE (type))
- {
- error_at (typespec_loc, "template placeholder type %qT must be followed "
- "by a simple declarator-id", type);
- inform (DECL_SOURCE_LOCATION (tmpl), "%qD declared here", tmpl);
- type = error_mark_node;
- }
+ {
+ auto_diagnostic_group g;
+ gcc_rich_location richloc (typespec_loc);
+ richloc.add_fixit_insert_after ("<>");
+ error_at (&richloc, "missing template argument list after %qE; "
+ "for deduction, template placeholder must be followed "
+ "by a simple declarator-id", tmpl);
+ inform (DECL_SOURCE_LOCATION (tmpl), "%qD declared here", tmpl);
+ type = error_mark_node;
+ }
staticp = 0;
inlinep = decl_spec_seq_has_spec_p (declspecs, ds_inline);
{
if (!funcdecl_p || !dguide_name_p (unqualified_id))
{
+ auto_diagnostic_group g;
error_at (typespec_loc, "deduced class "
"type %qD in function return type",
DECL_NAME (tmpl));
else if (tree c = CLASS_PLACEHOLDER_TEMPLATE (auto_node))
{
auto_diagnostic_group g;
- error_at (typespec_loc,
- "class template placeholder %qE not permitted "
- "in this context", c);
+ gcc_rich_location richloc (typespec_loc);
+ richloc.add_fixit_insert_after ("<>");
+ error_at (&richloc,
+ "missing template argument list after %qE; template "
+ "placeholder not permitted in parameter", c);
if (decl_context == PARM && cxx_dialect >= cxx20)
- inform (typespec_loc, "use %<auto%> for an "
+ inform (typespec_loc, "or use %<auto%> for an "
"abbreviated function template");
+ inform (DECL_SOURCE_LOCATION (c), "%qD declared here", c);
}
else
error_at (typespec_loc,
location_t loc = type_specifier_seq.locations[ds_type_spec];
if (tree tmpl = CLASS_PLACEHOLDER_TEMPLATE (auto_node))
{
- error_at (loc, "missing template arguments after %qT",
- auto_node);
+ auto_diagnostic_group g;
+ gcc_rich_location richloc (loc);
+ richloc.add_fixit_insert_after ("<>");
+ error_at (&richloc, "missing template arguments after %qE",
+ tmpl);
inform (DECL_SOURCE_LOCATION (tmpl), "%qD declared here",
tmpl);
}