re PR c++/65646 (ICE in invalid syntax)
authorJason Merrill <jason@redhat.com>
Wed, 1 Apr 2015 16:36:50 +0000 (12:36 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 1 Apr 2015 16:36:50 +0000 (12:36 -0400)
PR c++/65646
* decl.c (grokvardecl): Don't call check_explicit_specialization
for non-template members of a class template.

From-SVN: r221810

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

index 946450b48b053a71c956b99ae63b44c93fe714d8..904c9206590a7904ac71a1536ba213757fe3f19c 100644 (file)
@@ -1,3 +1,9 @@
+2015-04-01  Jason Merrill  <jason@redhat.com>
+
+       PR c++/65646
+       * decl.c (grokvardecl): Don't call check_explicit_specialization
+       for non-template members of a class template.
+
 2015-04-01  Marek Polacek  <polacek@redhat.com>
 
        PR c++/65554
index f05aefaddfbac364b0b24a0483419845c8327048..31b8e0cf50a68b7d759e012dda092c264d724bd2 100644 (file)
@@ -8210,7 +8210,9 @@ grokvardecl (tree type,
     DECL_INTERFACE_KNOWN (decl) = 1;
 
   // Handle explicit specializations and instantiations of variable templates.
-  if (orig_declarator)
+  if (orig_declarator
+      /* For GCC 5 fix 65646 this way.  */
+      && current_tmpl_spec_kind (template_count) != tsk_none)
     decl = check_explicit_specialization (orig_declarator, decl,
                                          template_count, 0);
 
diff --git a/gcc/testsuite/g++.dg/template/static36.C b/gcc/testsuite/g++.dg/template/static36.C
new file mode 100644 (file)
index 0000000..36c48b0
--- /dev/null
@@ -0,0 +1,4 @@
+// PR c++/65646
+
+template <typename = int> class A {};
+template <> A<> &A<>::a;       // { dg-error "" }