aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2018-04-04 12:42:55 -0400
committerJason Merrill <jason@gcc.gnu.org>2018-04-04 12:42:55 -0400
commit600583ab730f6cedd762b0e46a14061e2a6e097c (patch)
tree54ab3d5311fc77f27568dd573c565d708ed3d3e5 /gcc
parent6173fb512fca3ae6595c584e9af3765400c5a3de (diff)
downloadgcc-600583ab730f6cedd762b0e46a14061e2a6e097c.zip
gcc-600583ab730f6cedd762b0e46a14061e2a6e097c.tar.gz
gcc-600583ab730f6cedd762b0e46a14061e2a6e097c.tar.bz2
PR c++/85135 - ICE with omitted template arguments.
* decl.c (grokdeclarator): Catch deduced class type in trailing return type. From-SVN: r259092
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/decl.c29
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/class-deduction53.C10
3 files changed, 33 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 0f85744..261bd06 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
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.
* decl.c (cp_finish_decl): If a concept initializer is missing, use
true.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 1cc2cd1..746084c 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -11100,20 +11100,29 @@ grokdeclarator (const cp_declarator *declarator,
name, type);
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, "deduction guide "
- "for %qT must have trailing return "
- "type", TREE_TYPE (tmpl));
- else
- error_at (declarator->id_loc, "deduced class "
- "type %qT in function return type",
- type);
+ error_at (declarator->id_loc, "deduced class "
+ "type %qD in function return type",
+ DECL_NAME (tmpl));
inform (DECL_SOURCE_LOCATION (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)
&& CLASSTYPE_TEMPLATE_INFO (late_return_type)
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction53.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction53.C
new file mode 100644
index 0000000..6025dc4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction53.C
@@ -0,0 +1,10 @@
+// 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" }