Commit 44000dbb by Jerry DeLisle

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
parent c17ee676
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> 2008-02-28 Daniel Franke <franke.daniel@gmail.com>
PR fortran/31463 PR fortran/31463
......
...@@ -2506,6 +2506,8 @@ gfc_match_implicit (void) ...@@ -2506,6 +2506,8 @@ gfc_match_implicit (void)
int c; int c;
match m; match m;
gfc_clear_ts (&ts);
/* We don't allow empty implicit statements. */ /* We don't allow empty implicit statements. */
if (gfc_match_eos () == MATCH_YES) if (gfc_match_eos () == MATCH_YES)
{ {
......
...@@ -1051,18 +1051,19 @@ find_array_element (gfc_constructor *cons, gfc_array_ref *ar, ...@@ -1051,18 +1051,19 @@ find_array_element (gfc_constructor *cons, gfc_array_ref *ar,
mpz_mul (span, span, tmp); mpz_mul (span, span, tmp);
} }
if (cons) for (nelemen = mpz_get_ui (offset); nelemen > 0; nelemen--)
{ {
for (nelemen = mpz_get_ui (offset); nelemen > 0; nelemen--) if (cons)
{ {
if (cons->iterator) if (cons->iterator)
{ {
cons = NULL; cons = NULL;
goto depart;
} goto depart;
cons = cons->next; }
} cons = cons->next;
} }
}
depart: depart:
mpz_clear (delta); mpz_clear (delta);
...@@ -1341,7 +1342,7 @@ find_array_section (gfc_expr *expr, gfc_ref *ref) ...@@ -1341,7 +1342,7 @@ find_array_section (gfc_expr *expr, gfc_ref *ref)
cons = base; cons = base;
} }
while (mpz_cmp (ptr, index) > 0) while (cons && cons->next && mpz_cmp (ptr, index) > 0)
{ {
mpz_add_ui (index, index, one); mpz_add_ui (index, index, one);
cons = cons->next; cons = cons->next;
......
...@@ -1275,6 +1275,7 @@ gfc_conv_scalar_char_value (gfc_symbol *sym, gfc_se *se, gfc_expr **expr) ...@@ -1275,6 +1275,7 @@ gfc_conv_scalar_char_value (gfc_symbol *sym, gfc_se *se, gfc_expr **expr)
if ((*expr)->expr_type == EXPR_CONSTANT) if ((*expr)->expr_type == EXPR_CONSTANT)
{ {
gfc_typespec ts; gfc_typespec ts;
gfc_clear_ts (&ts);
*expr = gfc_int_expr ((int)(*expr)->value.character.string[0]); *expr = gfc_int_expr ((int)(*expr)->value.character.string[0]);
if ((*expr)->ts.kind != gfc_c_int_kind) if ((*expr)->ts.kind != gfc_c_int_kind)
...@@ -2250,6 +2251,7 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym, ...@@ -2250,6 +2251,7 @@ gfc_conv_function_call (gfc_se * se, gfc_symbol * sym,
stringargs = NULL_TREE; stringargs = NULL_TREE;
var = NULL_TREE; var = NULL_TREE;
len = NULL_TREE; len = NULL_TREE;
gfc_clear_ts (&ts);
if (sym->from_intmod == INTMOD_ISO_C_BINDING) if (sym->from_intmod == INTMOD_ISO_C_BINDING)
{ {
......
...@@ -3764,6 +3764,8 @@ gfc_conv_intrinsic_sr_kind (gfc_se *se, gfc_expr *expr) ...@@ -3764,6 +3764,8 @@ gfc_conv_intrinsic_sr_kind (gfc_se *se, gfc_expr *expr)
else else
{ {
gfc_typespec ts; gfc_typespec ts;
gfc_clear_ts (&ts);
if (actual->expr->ts.kind != gfc_c_int_kind) if (actual->expr->ts.kind != gfc_c_int_kind)
{ {
/* The arguments to SELECTED_REAL_KIND are INTEGER(4). */ /* The arguments to SELECTED_REAL_KIND are INTEGER(4). */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment