From 5c505cbacf8a90db83e3727ad6a1cb7f52b82dae Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 22 Feb 2013 17:24:40 -0500 Subject: [PATCH] re PR c++/40405 (ICE with invalid initialization of template member) PR c++/40405 * pt.c (push_template_decl_real): Set DECL_INTERFACE_KNOWN if we got the wrong number of template parms. From-SVN: r196231 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/pt.c | 2 ++ gcc/testsuite/g++.dg/template/error49.C | 10 ++++++++++ 3 files changed, 16 insertions(+) create mode 100644 gcc/testsuite/g++.dg/template/error49.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ed5d3995b35..4a2baa00ad5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2013-02-22 Jason Merrill + PR c++/40405 + * pt.c (push_template_decl_real): Set DECL_INTERFACE_KNOWN + if we got the wrong number of template parms. + PR c++/56377 * pt.c (fn_type_unification): Use explicit args in template instantiation context. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a39d114818f..5ff08211ebc 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -4782,6 +4782,8 @@ push_template_decl_real (tree decl, bool is_friend) error ("got %d template parameters for %q#T", TREE_VEC_LENGTH (a), current); error (" but %d required", TREE_VEC_LENGTH (t)); + /* Avoid crash in import_export_decl. */ + DECL_INTERFACE_KNOWN (decl) = 1; return error_mark_node; } diff --git a/gcc/testsuite/g++.dg/template/error49.C b/gcc/testsuite/g++.dg/template/error49.C new file mode 100644 index 00000000000..57789a79aa9 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/error49.C @@ -0,0 +1,10 @@ +// PR c++/40405 + +template struct A +{ + static int i; +}; + +template int A<0,0>::i = 0; // { dg-error "" } + +int j = A<0,0>::i; -- 2.30.2