From f87cb0b73403b26113c52b5efa70e93332053dfe Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 1 Apr 2015 12:36:50 -0400 Subject: [PATCH] re PR c++/65646 (ICE in invalid syntax) 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 | 6 ++++++ gcc/cp/decl.c | 4 +++- gcc/testsuite/g++.dg/template/static36.C | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/static36.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 946450b48b0..904c9206590 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-04-01 Jason Merrill + + 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 PR c++/65554 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index f05aefaddfb..31b8e0cf50a 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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 index 00000000000..36c48b021b1 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/static36.C @@ -0,0 +1,4 @@ +// PR c++/65646 + +template class A {}; +template <> A<> &A<>::a; // { dg-error "" } -- 2.30.2