Commit 600583ab by Jason Merrill Committed by Jason Merrill

PR c++/85135 - ICE with omitted template arguments.

	* decl.c (grokdeclarator): Catch deduced class type in trailing
	return type.

From-SVN: r259092
parent 6173fb51
2018-04-04 Jason Merrill <jason@redhat.com> 2018-04-04 Jason Merrill <jason@redhat.com>
PR c++/85135 - ICE with omitted template arguments.
* decl.c (grokdeclarator): Catch deduced class type in trailing
return type.
PR c++/85133 - ICE with missing concept initializer. PR c++/85133 - ICE with missing concept initializer.
* decl.c (cp_finish_decl): If a concept initializer is missing, use * decl.c (cp_finish_decl): If a concept initializer is missing, use
true. true.
......
...@@ -11100,20 +11100,29 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -11100,20 +11100,29 @@ grokdeclarator (const cp_declarator *declarator,
name, type); name, type);
return error_mark_node; return error_mark_node;
} }
if (tree tmpl = CLASS_PLACEHOLDER_TEMPLATE (auto_node)) tree tmpl = CLASS_PLACEHOLDER_TEMPLATE (auto_node);
if (!tmpl)
if (tree late_auto = type_uses_auto (late_return_type))
tmpl = CLASS_PLACEHOLDER_TEMPLATE (late_auto);
if (tmpl)
{ {
if (!late_return_type) if (!dguide_name_p (unqualified_id))
{ {
if (dguide_name_p (unqualified_id)) error_at (declarator->id_loc, "deduced class "
error_at (declarator->id_loc, "deduction guide " "type %qD in function return type",
"for %qT must have trailing return " DECL_NAME (tmpl));
"type", TREE_TYPE (tmpl));
else
error_at (declarator->id_loc, "deduced class "
"type %qT in function return type",
type);
inform (DECL_SOURCE_LOCATION (tmpl), inform (DECL_SOURCE_LOCATION (tmpl),
"%qD declared here", tmpl); "%qD declared here", tmpl);
return error_mark_node;
}
else if (!late_return_type)
{
error_at (declarator->id_loc, "deduction guide "
"for %qT must have trailing return "
"type", TREE_TYPE (tmpl));
inform (DECL_SOURCE_LOCATION (tmpl),
"%qD declared here", tmpl);
return error_mark_node;
} }
else if (CLASS_TYPE_P (late_return_type) else if (CLASS_TYPE_P (late_return_type)
&& CLASSTYPE_TEMPLATE_INFO (late_return_type) && CLASSTYPE_TEMPLATE_INFO (late_return_type)
......
// PR c++/85135
// { dg-do compile { target c++11 } }
template<int> struct A {};
auto foo() -> A; // { dg-error "A" }
template<typename> struct B {};
auto foo() -> A; // { dg-error "A" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment