error.c (dump_decl): Avoid crashing when presented with a uninitialized constant...

Tue Sep  9 17:57:25 1997  Mark Mitchell  <mmitchell@usa.net>

	* error.c (dump_decl): Avoid crashing when presented with a
	uninitialized constant, as can occur with a template parameter.

From-SVN: r15208
This commit is contained in:
Mark Mitchell 1997-09-10 02:28:20 +00:00 committed by Jason Merrill
parent a2676865a6
commit 0355541399
2 changed files with 36 additions and 24 deletions

View File

@ -1,3 +1,8 @@
Tue Sep 9 17:57:25 1997 Mark Mitchell <mmitchell@usa.net>
* error.c (dump_decl): Avoid crashing when presented with a
uninitialized constant, as can occur with a template parameter.
1997-09-09 Brendan Kehoe <brendan@lisa.cygnus.com> 1997-09-09 Brendan Kehoe <brendan@lisa.cygnus.com>
* typeck.c (build_indirect_ref): Heed FLAG_VOLATILE similar to * typeck.c (build_indirect_ref): Heed FLAG_VOLATILE similar to

View File

@ -782,10 +782,13 @@ dump_decl (t, v)
case CONST_DECL: case CONST_DECL:
if ((TREE_TYPE (t) != NULL_TREE && NEXT_CODE (t) == ENUMERAL_TYPE) if ((TREE_TYPE (t) != NULL_TREE && NEXT_CODE (t) == ENUMERAL_TYPE)
|| TREE_CODE (DECL_INITIAL (t)) == TEMPLATE_CONST_PARM) || (DECL_INITIAL (t) &&
TREE_CODE (DECL_INITIAL (t)) == TEMPLATE_CONST_PARM))
goto general; goto general;
else else if (DECL_INITIAL (t))
dump_expr (DECL_INITIAL (t), 0); dump_expr (DECL_INITIAL (t), 0);
else
OB_PUTS ("enumerator");
break; break;
case USING_DECL: case USING_DECL:
@ -1363,29 +1366,33 @@ dump_expr (t, nop)
} }
case TEMPLATE_CONST_PARM: case TEMPLATE_CONST_PARM:
if (current_template_parms) {
{ int l = current_template_parms ?
int i; list_length (current_template_parms) : 0;
int l = list_length (current_template_parms);
tree parms = current_template_parms;
tree r;
for (i = 0; i < l - TEMPLATE_CONST_LEVEL (t); ++i) if (l >= TEMPLATE_CONST_LEVEL (t))
{ {
parms = TREE_CHAIN (parms); int i;
my_friendly_assert (parms != NULL_TREE, 0); tree parms = current_template_parms;
} tree r;
r = TREE_VEC_ELT (TREE_VALUE (parms), for (i = 0; i < l - TEMPLATE_CONST_LEVEL (t); ++i)
TEMPLATE_CONST_IDX (t)); {
dump_decl (TREE_VALUE (r), -1); parms = TREE_CHAIN (parms);
} my_friendly_assert (parms != NULL_TREE, 0);
else }
{
OB_PUTS ("<tparm "); r = TREE_VEC_ELT (TREE_VALUE (parms),
OB_PUTI (TEMPLATE_CONST_IDX (t)); TEMPLATE_CONST_IDX (t));
OB_PUTS (">"); dump_decl (TREE_VALUE (r), -1);
} }
else
{
OB_PUTS ("<tparm ");
OB_PUTI (TEMPLATE_CONST_IDX (t));
OB_PUTS (">");
}
}
break; break;
case IDENTIFIER_NODE: case IDENTIFIER_NODE: