This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ Patch] PR 37650
- From: Paolo Carlini <paolo dot carlini at oracle dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Cc: Mark Mitchell <mark at codesourcery dot com>
- Date: Mon, 13 Oct 2008 11:08:58 +0200
- Subject: [C++ Patch] PR 37650
Hi,
this small patch avoids the ICE, tested x86_64-linux. Alternately, we
could return error_mark_node (that leads to an additional error message
("expected unqualified-id..."), or/and we could check
current_template_parms in the (only) caller push_template_decl_real). I
don't have a strong opinion...
Ok for mainline?
Paolo.
////////////////////
/cp
2008-10-13 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/37650
* pt.c (process_partial_specialization): Check that
current_template_parms is not null.
/testsuite
2008-10-13 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/37650
* g++.dg/template/crash83.C: New.
Index: testsuite/g++.dg/template/crash83.C
===================================================================
*** testsuite/g++.dg/template/crash83.C (revision 0)
--- testsuite/g++.dg/template/crash83.C (revision 0)
***************
*** 0 ****
--- 1,5 ----
+ // PR c++/37650
+
+ template<int> struct A {};
+
+ template<typename = class A<0>: > struct B {}; // { dg-error "explicit specialization|expected" }
Index: cp/pt.c
===================================================================
*** cp/pt.c (revision 141074)
--- cp/pt.c (working copy)
*************** process_partial_specialization (tree dec
*** 3292,3306 ****
tree maintmpl = CLASSTYPE_TI_TEMPLATE (type);
tree specargs = CLASSTYPE_TI_ARGS (type);
tree inner_args = INNERMOST_TEMPLATE_ARGS (specargs);
- tree inner_parms = INNERMOST_TEMPLATE_PARMS (current_template_parms);
tree main_inner_parms = DECL_INNERMOST_TEMPLATE_PARMS (maintmpl);
int nargs = TREE_VEC_LENGTH (inner_args);
! int ntparms = TREE_VEC_LENGTH (inner_parms);
int i;
int did_error_intro = 0;
struct template_parm_data tpd;
struct template_parm_data tpd2;
/* We check that each of the template parameters given in the
partial specialization is used in the argument list to the
specialization. For example:
--- 3292,3312 ----
tree maintmpl = CLASSTYPE_TI_TEMPLATE (type);
tree specargs = CLASSTYPE_TI_ARGS (type);
tree inner_args = INNERMOST_TEMPLATE_ARGS (specargs);
tree main_inner_parms = DECL_INNERMOST_TEMPLATE_PARMS (maintmpl);
+ tree inner_parms;
int nargs = TREE_VEC_LENGTH (inner_args);
! int ntparms;
int i;
int did_error_intro = 0;
struct template_parm_data tpd;
struct template_parm_data tpd2;
+ if (!current_template_parms)
+ return decl;
+
+ inner_parms = INNERMOST_TEMPLATE_PARMS (current_template_parms);
+ ntparms = TREE_VEC_LENGTH (inner_parms);
+
/* We check that each of the template parameters given in the
partial specialization is used in the argument list to the
specialization. For example: