Commit 36abe895 by Tobias Burnus Committed by Tobias Burnus

expr.c (find_array_element): Don't copy expr.

2013-04-18  Tobias Burnus  <burnus@net-b.de>

        * expr.c (find_array_element): Don't copy expr.
        * data.c (create_character_initializer): Free expr.
        * frontend-passes.c (combine_array_constructor): Ditto.
        * match.c (match_typebound_call, gfc_match_select_type): Ditto.
        * resolve.c (resolve_typebound_function): Free gfc_ref.

From-SVN: r198068
parent 6f5a366a
2013-04-18 Tobias Burnus <burnus@net-b.de> 2013-04-18 Tobias Burnus <burnus@net-b.de>
* expr.c (find_array_element): Don't copy expr.
* data.c (create_character_initializer): Free expr.
* frontend-passes.c (combine_array_constructor): Ditto.
* match.c (match_typebound_call, gfc_match_select_type): Ditto.
* resolve.c (resolve_typebound_function): Free gfc_ref.
2013-04-18 Tobias Burnus <burnus@net-b.de>
PR fortran/56994 PR fortran/56994
* invoke.texi (NEAREST): S argument is not optional. * invoke.texi (NEAREST): S argument is not optional.
......
...@@ -106,6 +106,7 @@ create_character_initializer (gfc_expr *init, gfc_typespec *ts, ...@@ -106,6 +106,7 @@ create_character_initializer (gfc_expr *init, gfc_typespec *ts,
{ {
int len, start, end; int len, start, end;
gfc_char_t *dest; gfc_char_t *dest;
bool alloced_init = false;
gfc_extract_int (ts->u.cl->length, &len); gfc_extract_int (ts->u.cl->length, &len);
...@@ -114,6 +115,7 @@ create_character_initializer (gfc_expr *init, gfc_typespec *ts, ...@@ -114,6 +115,7 @@ create_character_initializer (gfc_expr *init, gfc_typespec *ts,
/* Create a new initializer. */ /* Create a new initializer. */
init = gfc_get_character_expr (ts->kind, NULL, NULL, len); init = gfc_get_character_expr (ts->kind, NULL, NULL, len);
init->ts = *ts; init->ts = *ts;
alloced_init = true;
} }
dest = init->value.character.string; dest = init->value.character.string;
...@@ -134,6 +136,10 @@ create_character_initializer (gfc_expr *init, gfc_typespec *ts, ...@@ -134,6 +136,10 @@ create_character_initializer (gfc_expr *init, gfc_typespec *ts,
{ {
gfc_error ("failure to simplify substring reference in DATA " gfc_error ("failure to simplify substring reference in DATA "
"statement at %L", &ref->u.ss.start->where); "statement at %L", &ref->u.ss.start->where);
gfc_free_expr (start_expr);
gfc_free_expr (end_expr);
if (alloced_init)
gfc_free_expr (init);
return NULL; return NULL;
} }
......
...@@ -1209,7 +1209,7 @@ find_array_element (gfc_constructor_base base, gfc_array_ref *ar, ...@@ -1209,7 +1209,7 @@ find_array_element (gfc_constructor_base base, gfc_array_ref *ar,
goto depart; goto depart;
} }
e = gfc_copy_expr (ar->start[i]); e = ar->start[i];
if (e->expr_type != EXPR_CONSTANT) if (e->expr_type != EXPR_CONSTANT)
{ {
cons = NULL; cons = NULL;
...@@ -1258,8 +1258,6 @@ depart: ...@@ -1258,8 +1258,6 @@ depart:
mpz_clear (offset); mpz_clear (offset);
mpz_clear (span); mpz_clear (span);
mpz_clear (tmp); mpz_clear (tmp);
if (e)
gfc_free_expr (e);
*rval = cons; *rval = cons;
return t; return t;
} }
......
...@@ -1073,6 +1073,7 @@ combine_array_constructor (gfc_expr *e) ...@@ -1073,6 +1073,7 @@ combine_array_constructor (gfc_expr *e)
gfc_free_expr (op1); gfc_free_expr (op1);
gfc_free_expr (op2); gfc_free_expr (op2);
gfc_free_expr (scalar);
e->value.constructor = newbase; e->value.constructor = newbase;
return true; return true;
......
...@@ -4077,11 +4077,15 @@ match_typebound_call (gfc_symtree* varst) ...@@ -4077,11 +4077,15 @@ match_typebound_call (gfc_symtree* varst)
if (m == MATCH_NO) if (m == MATCH_NO)
gfc_error ("Expected component reference at %C"); gfc_error ("Expected component reference at %C");
if (m != MATCH_YES) if (m != MATCH_YES)
return MATCH_ERROR; {
gfc_free_expr (base);
return MATCH_ERROR;
}
if (gfc_match_eos () != MATCH_YES) if (gfc_match_eos () != MATCH_YES)
{ {
gfc_error ("Junk after CALL at %C"); gfc_error ("Junk after CALL at %C");
gfc_free_expr (base);
return MATCH_ERROR; return MATCH_ERROR;
} }
...@@ -4093,6 +4097,7 @@ match_typebound_call (gfc_symtree* varst) ...@@ -4093,6 +4097,7 @@ match_typebound_call (gfc_symtree* varst)
{ {
gfc_error ("Expected type-bound procedure or procedure pointer component " gfc_error ("Expected type-bound procedure or procedure pointer component "
"at %C"); "at %C");
gfc_free_expr (base);
return MATCH_ERROR; return MATCH_ERROR;
} }
new_st.expr1 = base; new_st.expr1 = base;
...@@ -5371,7 +5376,7 @@ gfc_match_select_type (void) ...@@ -5371,7 +5376,7 @@ gfc_match_select_type (void)
{ {
m = gfc_match (" %e ", &expr1); m = gfc_match (" %e ", &expr1);
if (m != MATCH_YES) if (m != MATCH_YES)
goto cleanup; return m;
} }
m = gfc_match (" )%t"); m = gfc_match (" )%t");
...@@ -5417,6 +5422,8 @@ gfc_match_select_type (void) ...@@ -5417,6 +5422,8 @@ gfc_match_select_type (void)
return MATCH_YES; return MATCH_YES;
cleanup: cleanup:
gfc_free_expr (expr1);
gfc_free_expr (expr2);
return m; return m;
} }
......
...@@ -5719,6 +5719,8 @@ resolve_typebound_function (gfc_expr* e) ...@@ -5719,6 +5719,8 @@ resolve_typebound_function (gfc_expr* e)
correct typespec. */ correct typespec. */
e->ts = ts; e->ts = ts;
} }
else if (new_ref)
gfc_free_ref_list (new_ref);
return true; return true;
} }
......
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