diff mbox

[C++] PR 58535

Message ID 524C4758.90403@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Oct. 2, 2013, 4:18 p.m. UTC
... oops attached the patch which I just committed. Sorry. Right 
attachments below.

Thanks,
Paolo.

//////////////////////
/cp
2013-10-02  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/58535
	* parser.c (cp_parser_function_specifier_opt): Upon error about
	virtual templates don't set ds_virtual.
	(finish_fully_implicit_template): Reject virtual implicit templates.

/testsuite
2013-10-02  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/58535
	* g++.dg/parse/crash65.C: New.
	* g++.dg/cpp1y/pr58535.C: Likewise.

Comments

Jason Merrill Oct. 2, 2013, 4:57 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: cp/parser.c
===================================================================
--- cp/parser.c	(revision 203110)
+++ cp/parser.c	(working copy)
@@ -11460,7 +11460,8 @@  cp_parser_function_specifier_opt (cp_parser* parse
 	 A member function template shall not be virtual.  */
       if (PROCESSING_REAL_TEMPLATE_DECL_P ())
 	error_at (token->location, "templates may not be %<virtual%>");
-      set_and_check_decl_spec_loc (decl_specs, ds_virtual, token);
+      else
+	set_and_check_decl_spec_loc (decl_specs, ds_virtual, token);
       break;
 
     case RID_EXPLICIT:
@@ -29035,6 +29036,14 @@  finish_fully_implicit_template (cp_parser *parser,
 {
   gcc_assert (parser->fully_implicit_function_template_p);
 
+  if (member_decl_opt && member_decl_opt != error_mark_node
+      && DECL_VIRTUAL_P (member_decl_opt))
+    {
+      error_at (DECL_SOURCE_LOCATION (member_decl_opt),
+		"implicit templates may not be %<virtual%>");
+      DECL_VIRTUAL_P (member_decl_opt) = false;
+    }
+
   pop_deferring_access_checks ();
   if (member_decl_opt)
     member_decl_opt = finish_member_template_decl (member_decl_opt);
Index: testsuite/g++.dg/cpp1y/pr58535.C
===================================================================
--- testsuite/g++.dg/cpp1y/pr58535.C	(revision 0)
+++ testsuite/g++.dg/cpp1y/pr58535.C	(working copy)
@@ -0,0 +1,7 @@ 
+// PR c++/58535
+// { dg-options "-std=gnu++1y" }
+
+struct A
+{
+  virtual void foo(auto); // { dg-error "templates" }
+};
Index: testsuite/g++.dg/parse/crash65.C
===================================================================
--- testsuite/g++.dg/parse/crash65.C	(revision 0)
+++ testsuite/g++.dg/parse/crash65.C	(working copy)
@@ -0,0 +1,6 @@ 
+// PR c++/58535
+
+struct A
+{
+  template<int> virtual void foo(); // { dg-error "templates" }
+};