summaryrefslogtreecommitdiff
path: root/gcc/fortran/expr.c
diff options
context:
space:
mode:
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>2007-12-09 09:17:24 +0000
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>2007-12-09 09:17:24 +0000
commita2f51d5f09a1394e3a45c7052c5223c1517c65ea (patch)
tree20e58b82c3459ec5c5b1e896dcce5b3ad27987fb /gcc/fortran/expr.c
parent4995f9f98a8e8cf1e1150baa6e9ae505a00a103b (diff)
downloadgcc-a2f51d5f09a1394e3a45c7052c5223c1517c65ea.tar.gz
2007-12-09 Paul Thomas <pault@gcc.gnu.org>
PR fortran/32129 * dump-parse-tree.c (gfc_show_expr_n): New function for debugging. * gfortran.h : Add prototype for gfc_show_expr_n. * expr.c (simplify_constructor): Copy the constructor expression and try to simplify that. If success, replace the original. Otherwise discard the copy, keep going through the structure and return success. PR fortran/31487 * decl.c (build_struct): Pad out default initializers with spaces to the component character length. 2007-12-09 Paul Thomas <pault@gcc.gnu.org> PR fortran/32129 * gfortran.dg/derived_comp_array_ref_6.f90: New test. * gfortran.dg/derived_comp_array_ref_7.f90: New test. PR fortran/31487 * gfortran.dg/char_component_initializer_1.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130719 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/expr.c')
-rw-r--r--gcc/fortran/expr.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 1242e5eb0a9..255acb6f188 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -963,6 +963,8 @@ simplify_intrinsic_op (gfc_expr *p, int type)
static try
simplify_constructor (gfc_constructor *c, int type)
{
+ gfc_expr *p;
+
for (; c; c = c->next)
{
if (c->iterator
@@ -971,8 +973,21 @@ simplify_constructor (gfc_constructor *c, int type)
|| gfc_simplify_expr (c->iterator->step, type) == FAILURE))
return FAILURE;
- if (c->expr && gfc_simplify_expr (c->expr, type) == FAILURE)
- return FAILURE;
+ if (c->expr)
+ {
+ /* Try and simplify a copy. Replace the original if successful
+ but keep going through the constructor at all costs. Not
+ doing so can make a dog's dinner of complicated things. */
+ p = gfc_copy_expr (c->expr);
+
+ if (gfc_simplify_expr (p, type) == FAILURE)
+ {
+ gfc_free_expr (p);
+ continue;
+ }
+
+ gfc_replace_expr (c->expr, p);
+ }
}
return SUCCESS;