summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2013-04-18 18:59:38 +0000
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2013-04-18 18:59:38 +0000
commitf48281e68974d269edd9184835decf7421fbb6eb (patch)
tree6ee281c2a3bcf72cd82191493519aeaf778bc791
parentfaeb0946876005bec9b168c28582f0109e73f272 (diff)
downloadgcc-f48281e68974d269edd9184835decf7421fbb6eb.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@198068 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/fortran/ChangeLog8
-rw-r--r--gcc/fortran/data.c6
-rw-r--r--gcc/fortran/expr.c4
-rw-r--r--gcc/fortran/frontend-passes.c1
-rw-r--r--gcc/fortran/match.c11
-rw-r--r--gcc/fortran/resolve.c2
6 files changed, 27 insertions, 5 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 0421d18d314..2f2d5ee440d 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,5 +1,13 @@
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
* invoke.texi (NEAREST): S argument is not optional.
diff --git a/gcc/fortran/data.c b/gcc/fortran/data.c
index f297ef56faf..a1c89fa1f06 100644
--- a/gcc/fortran/data.c
+++ b/gcc/fortran/data.c
@@ -106,6 +106,7 @@ create_character_initializer (gfc_expr *init, gfc_typespec *ts,
{
int len, start, end;
gfc_char_t *dest;
+ bool alloced_init = false;
gfc_extract_int (ts->u.cl->length, &len);
@@ -114,6 +115,7 @@ create_character_initializer (gfc_expr *init, gfc_typespec *ts,
/* Create a new initializer. */
init = gfc_get_character_expr (ts->kind, NULL, NULL, len);
init->ts = *ts;
+ alloced_init = true;
}
dest = init->value.character.string;
@@ -134,6 +136,10 @@ create_character_initializer (gfc_expr *init, gfc_typespec *ts,
{
gfc_error ("failure to simplify substring reference in DATA "
"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;
}
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 490cdaaf2d8..ab62c180d3d 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -1209,7 +1209,7 @@ find_array_element (gfc_constructor_base base, gfc_array_ref *ar,
goto depart;
}
- e = gfc_copy_expr (ar->start[i]);
+ e = ar->start[i];
if (e->expr_type != EXPR_CONSTANT)
{
cons = NULL;
@@ -1258,8 +1258,6 @@ depart:
mpz_clear (offset);
mpz_clear (span);
mpz_clear (tmp);
- if (e)
- gfc_free_expr (e);
*rval = cons;
return t;
}
diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c
index 3946c0c3461..68e7e053056 100644
--- a/gcc/fortran/frontend-passes.c
+++ b/gcc/fortran/frontend-passes.c
@@ -1073,6 +1073,7 @@ combine_array_constructor (gfc_expr *e)
gfc_free_expr (op1);
gfc_free_expr (op2);
+ gfc_free_expr (scalar);
e->value.constructor = newbase;
return true;
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index b5e9609d965..07f8f638727 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -4077,11 +4077,15 @@ match_typebound_call (gfc_symtree* varst)
if (m == MATCH_NO)
gfc_error ("Expected component reference at %C");
if (m != MATCH_YES)
- return MATCH_ERROR;
+ {
+ gfc_free_expr (base);
+ return MATCH_ERROR;
+ }
if (gfc_match_eos () != MATCH_YES)
{
gfc_error ("Junk after CALL at %C");
+ gfc_free_expr (base);
return MATCH_ERROR;
}
@@ -4093,6 +4097,7 @@ match_typebound_call (gfc_symtree* varst)
{
gfc_error ("Expected type-bound procedure or procedure pointer component "
"at %C");
+ gfc_free_expr (base);
return MATCH_ERROR;
}
new_st.expr1 = base;
@@ -5371,7 +5376,7 @@ gfc_match_select_type (void)
{
m = gfc_match (" %e ", &expr1);
if (m != MATCH_YES)
- goto cleanup;
+ return m;
}
m = gfc_match (" )%t");
@@ -5417,6 +5422,8 @@ gfc_match_select_type (void)
return MATCH_YES;
cleanup:
+ gfc_free_expr (expr1);
+ gfc_free_expr (expr2);
return m;
}
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 90bce536c2d..6e1f56f707d 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -5719,6 +5719,8 @@ resolve_typebound_function (gfc_expr* e)
correct typespec. */
e->ts = ts;
}
+ else if (new_ref)
+ gfc_free_ref_list (new_ref);
return true;
}