We were failing to give an error for B::foo not having a definition to
deduce the return type from; an easy way to avoid the ICE is to promote
the existing permerror about 'virtual auto' to a full error.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 62fa8dfdd93b964246d06f3d5b41a3c2659509f3
Author: Jason Merrill <ja...@redhat.com>
Date: Thu Mar 20 17:14:19 2014 -0400
PR c++/60574
* decl.c (grokdeclarator): Change permerror about 'virtual auto'
to error.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 4eb3e69..c912ffc 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -9553,8 +9553,8 @@ grokdeclarator (const cp_declarator *declarator,
"-std=gnu++1y");
}
else if (virtualp)
- permerror (input_location, "virtual function cannot "
- "have deduced return type");
+ error ("virtual function cannot "
+ "have deduced return type");
}
else if (!is_auto (type))
{
diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn25.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn25.C
new file mode 100644
index 0000000..628a685
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn25.C
@@ -0,0 +1,15 @@
+// PR c++/60574
+// { dg-options "-flto" }
+// { dg-do compile { target c++1y } }
+
+struct A
+{
+ virtual auto foo() {} // { dg-error "virtual.*deduced" }
+};
+
+struct B : A
+{
+ auto foo();
+};
+
+B b;