------- Comment #6 from pault at gcc dot gnu dot org  2007-04-13 23:24 -------
This cures the problem but is otherwise untested.

Paul

Index: gcc/fortran/decl.c
===================================================================
*** gcc/fortran/decl.c  (revision 123793)
--- gcc/fortran/decl.c  (working copy)
*************** add_init_expr_to_sym (const char *name,
*** 972,978 ****

        /* Add initializer.  Make sure we keep the ranks sane.  */
        if (sym->attr.dimension && init->rank == 0)
!       init->rank = sym->as->rank;

        sym->value = init;
        *initp = NULL;
--- 972,1001 ----

        /* Add initializer.  Make sure we keep the ranks sane.  */
        if (sym->attr.dimension && init->rank == 0)
!       {
!         mpz_t size;
!         gfc_constructor *ctor, *tail;
!         int n;
!         if (sym->attr.flavor == FL_PARAMETER
!               && init->expr_type == EXPR_CONSTANT)
!           {
!             spec_size (sym->as, &size);
!             ctor = tail = gfc_get_constructor ();
!             ctor->expr = init;
!             for (n = 1; n < (int)mpz_get_si (size); n++)
!               {
!                 tail->next = gfc_get_constructor ();
!                 tail = tail->next;
!                 tail->expr = gfc_copy_expr (init);
!               }
!             init = gfc_get_expr ();
!             init->expr_type = EXPR_ARRAY;
!             init->ts = ctor->expr->ts;
!             init->value.constructor = ctor;
!             mpz_clear (size);
!           }
!         init->rank = sym->as->rank;
!       }

        sym->value = init;
        *initp = NULL;


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29397

Reply via email to