public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/64129 (ICE on ill-formed template)
@ 2014-12-10  2:47 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2014-12-10  2:47 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 144 bytes --]

We should check whether the template we're trying to specialize is the 
right kind of template.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: 64129.patch --]
[-- Type: text/x-patch, Size: 1411 bytes --]

commit af5860b1a4bac653093a74d97a00b162c2b1add7
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Dec 9 12:53:26 2014 -0500

    	PR c++/64129
    	* decl.c (grokdeclarator): Recover from variable template
    	specialization declared as function.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 5639b3d..9659336 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -10739,6 +10739,19 @@ grokdeclarator (const cp_declarator *declarator,
 		return error_mark_node;
 	      }
 
+	    if (TREE_CODE (unqualified_id) == TEMPLATE_ID_EXPR)
+	      {
+		tree tmpl = TREE_OPERAND (unqualified_id, 0);
+		if (variable_template_p (tmpl))
+		  {
+		    error ("specialization of variable template %qD "
+			   "declared as function", tmpl);
+		    inform (DECL_SOURCE_LOCATION (tmpl),
+			    "variable template declared here");
+		    return error_mark_node;
+		  }
+	      }
+
 	    /* Tell grokfndecl if it needs to set TREE_PUBLIC on the node.  */
 	    function_context = (ctype != NULL_TREE) ?
 	      decl_function_context (TYPE_MAIN_DECL (ctype)) : NULL_TREE;
diff --git a/gcc/testsuite/g++.dg/parse/error56.C b/gcc/testsuite/g++.dg/parse/error56.C
new file mode 100644
index 0000000..7c81ab4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/error56.C
@@ -0,0 +1,5 @@
+// PR c++/64129
+
+template <0> int __copy_streambufs_eof; // { dg-error "" }
+class {
+    friend __copy_streambufs_eof <> ( // { dg-error "" }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-12-10  2:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-10  2:47 C++ PATCH for c++/64129 (ICE on ill-formed template) Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).