]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/64129 (ICE on invalid: in grokfndecl, at cp/decl.c:7658)
authorJason Merrill <jason@redhat.com>
Wed, 10 Dec 2014 02:51:03 +0000 (21:51 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 10 Dec 2014 02:51:03 +0000 (21:51 -0500)
PR c++/64129
* decl.c (grokdeclarator): Recover from variable template
specialization declared as function.

From-SVN: r218557

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/parse/error56.C [new file with mode: 0644]

index 8a8b536a53d47b557b471c1bd4950fb411d15a1a..484dd2863695b9457f21175289c9c97a2613d11d 100644 (file)
@@ -1,5 +1,9 @@
 2014-12-09  Jason Merrill  <jason@redhat.com>
 
+       PR c++/64129
+       * decl.c (grokdeclarator): Recover from variable template
+       specialization declared as function.
+
        PR c++/64222
        * parser.c (cp_parser_unqualified_id): Don't declare fname while
        parsing function parms.
index 5639b3d54c80b27dcc17d1b28e4370c3214fc0e9..9659336f01d122e734aab67abd09a20afa563de1 100644 (file)
@@ -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 (file)
index 0000000..7c81ab4
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/64129
+
+template <0> int __copy_streambufs_eof; // { dg-error "" }
+class {
+    friend __copy_streambufs_eof <> ( // { dg-error "" }