]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/58535 (ICE with virtual template function)
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 2 Oct 2013 18:25:55 +0000 (18:25 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 2 Oct 2013 18:25:55 +0000 (18:25 +0000)
/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.

From-SVN: r203123

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/pr58535.C [new file with mode: 0644]
gcc/testsuite/g++.dg/parse/crash65.C [new file with mode: 0644]

index 55655c60bec02fdcfac0bacd901954b4967eab90..c984f9030f3815ca9831feb22aae8de607877818 100644 (file)
@@ -1,3 +1,10 @@
+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.
+
 2013-10-02  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/58565
index 5e68b363a3530e4b739702ca43f6d170c16d93bc..d0a23f3c3b84ed9227939e8b70050eef351198b1 100644 (file)
@@ -11460,7 +11460,8 @@ cp_parser_function_specifier_opt (cp_parser* parser,
         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, tree member_decl_opt)
 {
   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 754a6a2f2934effb2c11a0f6f442ee843c09ea1a..ec43cc5e021000ccce2d3783c31f77a711224bff 100644 (file)
@@ -1,3 +1,9 @@
+2013-10-02  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/58535
+       * g++.dg/parse/crash65.C: New.
+       * g++.dg/cpp1y/pr58535.C: Likewise.
+
 2013-10-02  Richard Biener  <rguenther@suse.de>
 
        * gcc.dg/tree-ssa/ldist-11.c: Adjust.
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr58535.C b/gcc/testsuite/g++.dg/cpp1y/pr58535.C
new file mode 100644 (file)
index 0000000..2bf62b0
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/58535
+// { dg-options "-std=gnu++1y" }
+
+struct A
+{
+  virtual void foo(auto); // { dg-error "templates" }
+};
diff --git a/gcc/testsuite/g++.dg/parse/crash65.C b/gcc/testsuite/g++.dg/parse/crash65.C
new file mode 100644 (file)
index 0000000..04154f4
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/58535
+
+struct A
+{
+  template<int> virtual void foo(); // { dg-error "templates" }
+};