Patchwork C++ PATCH for c++/60574 (ICE with 'virtual auto')

login
register
mail settings
Submitter Jason Merrill
Date March 22, 2014, 4:27 a.m.
Message ID <532D1118.3010906@redhat.com>
Download mbox | patch
Permalink /patch/332793/
State New
Headers show

Comments

Jason Merrill - March 22, 2014, 4:27 a.m.
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.

Patch

commit 62fa8dfdd93b964246d06f3d5b41a3c2659509f3
Author: Jason Merrill <jason@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;