re PR fortran/35059 (Seg fault when max constructor limit reached)

2008-02-29  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/35059
	* expr.c (find_array_element): Modify traversing the constructor to
	avoid trying to access NULL memory pointed to by next for the
	last element. (find_array_section): Exit while loop if cons->next is
	NULL.
	* trans-expr.c (gfc_conv_scalar_char_value): Initialize gfc_typespec.
	(gfc_conv_function_call): Same.
	* decl.c (gfc_match_implicit): Same.
	* trans-intrinsic.c (gfc_conv_intrinsic_sr_kind): Same.

From-SVN: r132782
This commit is contained in:
Jerry DeLisle 2008-02-29 22:50:25 +00:00
parent c17ee676e5
commit 44000dbbe0
5 changed files with 32 additions and 13 deletions

View File

@ -1,3 +1,15 @@
2008-02-29 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/35059
* expr.c (find_array_element): Modify traversing the constructor to
avoid trying to access NULL memory pointed to by next for the
last element. (find_array_section): Exit while loop if cons->next is
NULL.
* trans-expr.c (gfc_conv_scalar_char_value): Initialize gfc_typespec.
(gfc_conv_function_call): Same.
* decl.c (gfc_match_implicit): Same.
* trans-intrinsic.c (gfc_conv_intrinsic_sr_kind): Same.
2008-02-28 Daniel Franke <franke.daniel@gmail.com>
PR fortran/31463

View File

@ -2506,6 +2506,8 @@ gfc_match_implicit (void)
int c;
match m;
gfc_clear_ts (&ts);
/* We don't allow empty implicit statements. */
if (gfc_match_eos () == MATCH_YES)
{

View File

@ -1051,18 +1051,19 @@ find_array_element (gfc_constructor *cons, gfc_array_ref *ar,
mpz_mul (span, span, tmp);
}
if (cons)
{
for (nelemen = mpz_get_ui (offset); nelemen > 0; nelemen--)
{
if (cons->iterator)
{
cons = NULL;
goto depart;
}
cons = cons->next;
}
}
for (nelemen = mpz_get_ui (offset); nelemen > 0; nelemen--)
{
if (cons)
{
if (cons->iterator)
{
cons = NULL;
goto depart;
}
cons = cons->next;
}
}
depart:
mpz_clear (delta);
@ -1341,7 +1342,7 @@ find_array_section (gfc_expr *expr, gfc_ref *ref)
cons = base;
}
while (mpz_cmp (ptr, index) > 0)
while (cons && cons->next && mpz_cmp (ptr, index) > 0)
{
mpz_add_ui (index, index, one);
cons = cons->next;

View File

@ -1275,6 +1275,7 @@ gfc_conv_scalar_char_value (gfc_symbol *sym, gfc_se *se, gfc_expr **expr)
if ((*expr)->expr_type == EXPR_CONSTANT)
{
gfc_typespec ts;
gfc_clear_ts (&ts);
*expr = gfc_int_expr ((int)(*expr)->value.character.string[0]);
if ((*expr)->ts.kind != gfc_c_int_kind)
@ -2250,6 +2251,7 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym,
stringargs = NULL_TREE;
var = NULL_TREE;
len = NULL_TREE;
gfc_clear_ts (&ts);
if (sym->from_intmod == INTMOD_ISO_C_BINDING)
{

View File

@ -3764,6 +3764,8 @@ gfc_conv_intrinsic_sr_kind (gfc_se *se, gfc_expr *expr)
else
{
gfc_typespec ts;
gfc_clear_ts (&ts);
if (actual->expr->ts.kind != gfc_c_int_kind)
{
/* The arguments to SELECTED_REAL_KIND are INTEGER(4). */