From 331c72f3db58cd93b1863aef4844a2ef883ae63a Mon Sep 17 00:00:00 2001 From: Paul Brook Date: Sat, 10 Jul 2004 22:55:40 +0000 Subject: trans-array.c (gfc_build_null_descriptor): New function. * trans-array.c (gfc_build_null_descriptor): New function. (gfc_trans_static_array_pointer): Use it. * trans-array.h (gfc_build_null_descriptor): Add prototype. * trans-expr.c (gfc_conv_structure): Handle array pointers. testsuite/ * gfortran.fortran-torture/execute/der_init_5.f90: Enable more tests. From-SVN: r84477 --- gcc/fortran/trans-array.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'gcc/fortran/trans-array.c') diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 731fb193099..62ecafe767d 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -288,27 +288,26 @@ gfc_conv_descriptor_ubound (tree desc, tree dim) } -/* Generate an initializer for a static pointer or allocatable array. */ +/* Build an null array descriptor constructor. */ -void -gfc_trans_static_array_pointer (gfc_symbol * sym) +tree +gfc_build_null_descriptor (tree type) { - tree tmp; tree field; - tree type; + tree tmp; - assert (TREE_STATIC (sym->backend_decl)); - /* Just zero the data member. */ - type = TREE_TYPE (sym->backend_decl); assert (GFC_DESCRIPTOR_TYPE_P (type)); assert (DATA_FIELD == 0); field = TYPE_FIELDS (type); + /* Set a NULL data pointer. */ tmp = tree_cons (field, null_pointer_node, NULL_TREE); tmp = build1 (CONSTRUCTOR, type, tmp); TREE_CONSTANT (tmp) = 1; TREE_INVARIANT (tmp) = 1; - DECL_INITIAL (sym->backend_decl) = tmp; + /* All other fields are ignored. */ + + return tmp; } @@ -422,6 +421,20 @@ gfc_add_ss_to_loop (gfc_loopinfo * loop, gfc_ss * head) } +/* Generate an initializer for a static pointer or allocatable array. */ + +void +gfc_trans_static_array_pointer (gfc_symbol * sym) +{ + tree type; + + assert (TREE_STATIC (sym->backend_decl)); + /* Just zero the data member. */ + type = TREE_TYPE (sym->backend_decl); + DECL_INITIAL (sym->backend_decl) =gfc_build_null_descriptor (type); +} + + /* Generate code to allocate an array temporary, or create a variable to hold the data. */ -- cgit v1.2.1