diff options
author | pault <pault@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-11-04 20:19:40 +0000 |
---|---|---|
committer | pault <pault@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-11-04 20:19:40 +0000 |
commit | 4442e7ec19d8973a89a1db6b6073e6c3429b14a7 (patch) | |
tree | 148e097852336d15e0998904c779d8782f968797 /gcc/fortran/trans-io.c | |
parent | 5c8091dde3ff97e4ee50f2957d960cc7bc9bd6a9 (diff) | |
download | gcc-4442e7ec19d8973a89a1db6b6073e6c3429b14a7.tar.gz |
2013-11-04 Paul Thomas <pault@gcc.gnu.org>
PR fortran/58771
* trans-io.c (transfer_expr): If the backend_decl for a derived
type is missing, build it with gfc_typenode_for_spec.
2013-11-04 Paul Thomas <pault@gcc.gnu.org>
PR fortran/58771
* gfortran.dg/derived_external_function_1.f90 : New test
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204358 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/trans-io.c')
-rw-r--r-- | gcc/fortran/trans-io.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/gcc/fortran/trans-io.c b/gcc/fortran/trans-io.c index ec17dc97c21..5fa1cdc091e 100644 --- a/gcc/fortran/trans-io.c +++ b/gcc/fortran/trans-io.c @@ -243,16 +243,16 @@ gfc_trans_io_runtime_check (tree cond, tree var, int error_code, /* The code to generate the error. */ gfc_start_block (&block); - + arg1 = gfc_build_addr_expr (NULL_TREE, var); - + arg2 = build_int_cst (integer_type_node, error_code), - + asprintf (&message, "%s", _(msgid)); arg3 = gfc_build_addr_expr (pchar_type_node, gfc_build_localized_cstring_const (message)); free (message); - + tmp = build_call_expr_loc (input_location, gfor_fndecl_generate_error, 3, arg1, arg2, arg3); @@ -521,7 +521,7 @@ set_parameter_value (stmtblock_t *block, tree var, enum iofield type, gfc_trans_io_runtime_check (cond, var, LIBERROR_BAD_UNIT, "Unit number in I/O statement too small", &se.pre); - + /* UNIT numbers should be less than the max. */ val = gfc_conv_mpz_to_tree (gfc_integer_kinds[i].huge, 4); cond = fold_build2_loc (input_location, GT_EXPR, boolean_type_node, @@ -1000,7 +1000,7 @@ gfc_trans_open (gfc_code * code) if (p->convert) mask |= set_string (&block, &post_block, var, IOPARM_open_convert, p->convert); - + if (p->newunit) mask |= set_parameter_ref (&block, &post_block, var, IOPARM_open_newunit, p->newunit); @@ -1234,7 +1234,7 @@ gfc_trans_inquire (gfc_code * code) { mask |= set_parameter_ref (&block, &post_block, var, IOPARM_inquire_exist, p->exist); - + if (p->unit && !p->iostat) { p->iostat = create_dummy_iostat (); @@ -1322,7 +1322,7 @@ gfc_trans_inquire (gfc_code * code) if (p->pad) mask |= set_string (&block, &post_block, var, IOPARM_inquire_pad, p->pad); - + if (p->convert) mask |= set_string (&block, &post_block, var, IOPARM_inquire_convert, p->convert); @@ -1547,7 +1547,7 @@ transfer_namelist_element (stmtblock_t * block, const char * var_name, tree dtype; tree dt_parm_addr; tree decl = NULL_TREE; - int n_dim; + int n_dim; int itype; int rank = 0; @@ -2029,7 +2029,7 @@ transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr, gfc_code * code) ts->type = BT_INTEGER; ts->kind = gfc_index_integer_kind; } - + kind = ts->kind; function = NULL; arg2 = NULL; @@ -2111,7 +2111,7 @@ transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr, gfc_code * code) function = iocall[IOCALL_X_CHARACTER_WIDE]; else function = iocall[IOCALL_X_CHARACTER_WIDE_WRITE]; - + tmp = gfc_build_addr_expr (NULL_TREE, dt_parm); tmp = build_call_expr_loc (input_location, function, 4, tmp, addr_expr, arg2, arg3); @@ -2146,6 +2146,12 @@ transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr, gfc_code * code) expr = build_fold_indirect_ref_loc (input_location, expr); + /* Make sure that the derived type has been built. An external + function, if only referenced in an io statement, requires this + check (see PR58771). */ + if (ts->u.derived->backend_decl == NULL_TREE) + tmp = gfc_typenode_for_spec (ts); + for (c = ts->u.derived->components; c; c = c->next) { field = c->backend_decl; |