From 08789087fc452a4857df45553c974fed82e31eb4 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 28 Aug 2007 18:08:57 +0200 Subject: [PATCH] re PR fortran/22244 (dimension information is lost for multi-dimension array) PR fortran/22244 * Make-lang.in (fortran/trans-types.o): Depend on $(FLAGS_H). * trans-types.c: Include flags.h. (gfc_get_nodesc_array_type): Add TYPE_DECL TYPE_NAME with correct bounds and dimensions for packed arrays. From-SVN: r127864 --- gcc/fortran/ChangeLog | 8 ++++++++ gcc/fortran/Make-lang.in | 2 +- gcc/fortran/trans-types.c | 21 ++++++++++++++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index e2ec1af83e9..dffd31ea69a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2007-08-28 Jakub Jelinek + + PR fortran/22244 + * Make-lang.in (fortran/trans-types.o): Depend on $(FLAGS_H). + * trans-types.c: Include flags.h. + (gfc_get_nodesc_array_type): Add TYPE_DECL TYPE_NAME with + correct bounds and dimensions for packed arrays. + 2007-08-27 Tobias Burnus * simplify.c (gfc_simplify_lgamma): Fix mpfr_lgamma call. diff --git a/gcc/fortran/Make-lang.in b/gcc/fortran/Make-lang.in index 4a9590a2cae..30320a84810 100644 --- a/gcc/fortran/Make-lang.in +++ b/gcc/fortran/Make-lang.in @@ -311,7 +311,7 @@ fortran/trans-decl.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-decl.h \ $(CGRAPH_H) $(TARGET_H) $(FUNCTION_H) $(FLAGS_H) $(RTL_H) $(TREE_GIMPLE_H) \ $(TREE_DUMP_H) fortran/trans-types.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-types.h \ - $(REAL_H) toplev.h $(TARGET_H) + $(REAL_H) toplev.h $(TARGET_H) $(FLAGS_H) fortran/trans-const.o: $(GFORTRAN_TRANS_DEPS) fortran/trans-expr.o: $(GFORTRAN_TRANS_DEPS) fortran/dependency.h fortran/trans-stmt.o: $(GFORTRAN_TRANS_DEPS) fortran/dependency.h diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index e1cac5de9df..b7c9c53bf21 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -36,6 +36,7 @@ along with GCC; see the file COPYING3. If not see #include "trans-types.h" #include "trans-const.h" #include "real.h" +#include "flags.h" #if (GFC_MAX_DIMENSIONS < 10) @@ -1232,7 +1233,7 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_spec * as, gfc_packed packed) { /* Fill in the stride and bound components of the type. */ if (known_stride) - tmp = gfc_conv_mpz_to_tree (stride, gfc_index_integer_kind); + tmp = gfc_conv_mpz_to_tree (stride, gfc_index_integer_kind); else tmp = NULL_TREE; GFC_TYPE_ARRAY_STRIDE (type, n) = tmp; @@ -1330,6 +1331,24 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_spec * as, gfc_packed packed) mpz_clear (stride); mpz_clear (delta); + /* In debug info represent packed arrays as multi-dimensional + if they have rank > 1 and with proper bounds, instead of flat + arrays. */ + if (known_stride && write_symbols != NO_DEBUG) + { + tree gtype = etype, rtype, type_decl; + + for (n = as->rank - 1; n >= 0; n--) + { + rtype = build_range_type (gfc_array_index_type, + GFC_TYPE_ARRAY_LBOUND (type, n), + GFC_TYPE_ARRAY_UBOUND (type, n)); + gtype = build_array_type (gtype, rtype); + } + TYPE_NAME (type) = type_decl = build_decl (TYPE_DECL, NULL, gtype); + DECL_ORIGINAL_TYPE (type_decl) = gtype; + } + if (packed != PACKED_STATIC || !known_stride) { /* For dummy arrays and automatic (heap allocated) arrays we -- 2.30.2