Bug 36824 - gfortran does not recognize constant array bounds in dimension attribute of type component
gfortran does not recognize constant array bounds in dimension attribute of t...
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: fortran
4.3.1
: P3 normal
: ---
Assigned To: Not yet assigned to anyone
: rejects-valid
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-07-14 15:43 UTC by Florian Ladstaedter
Modified: 2008-07-17 09:46 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Ladstaedter 2008-07-14 15:43:49 UTC
---------------------------------
program test

implicit none

integer, dimension( 3 ), parameter :: tgc = (/5, 6, 7 /)

type tgccomp
   integer, dimension( tgc( 1 ) : tgc( 2 ) ) :: tgclist
end type tgccomp

end program
---------------------------------

This gives the following error:

gfortran test.f90
test.f90:8.73:

   integer, dimension( tgc( 1 ) : tgc( 2 ) ) :: tgclist
                                                                        1
Error: Component 'tgclist' of 'tgccomp' at (1) must have constant array bounds


This works:
---------------------------------
type tgccomp
   integer, dimension( 1 : tgc( 1 ) ) :: tgclist
end type tgccomp
---------------------------------
Comment 1 Tobias Burnus 2008-07-14 19:30:14 UTC
The following seems to fix it.

Index: resolve.c
===================================================================
--- resolve.c   (Revision 137789)
+++ resolve.c   (Arbeitskopie)
@@ -7682,8 +7805,8 @@ resolve_fl_derived (gfc_symbol *sym)
       for (i = 0; i < c->as->rank; i++)
        {
          if (c->as->lower[i] == NULL
-             || !gfc_is_constant_expr (c->as->lower[i])
              || (resolve_index_expr (c->as->lower[i]) == FAILURE)
+             || !gfc_is_constant_expr (c->as->lower[i])
              || c->as->upper[i] == NULL
              || (resolve_index_expr (c->as->upper[i]) == FAILURE)
              || !gfc_is_constant_expr (c->as->upper[i]))
Comment 2 Tobias Burnus 2008-07-17 05:55:32 UTC
Subject: Bug 36824

Author: burnus
Date: Thu Jul 17 05:54:42 2008
New Revision: 137910

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137910
Log:
2008-07-17  Tobias Burnus  <burnus@net-b.de>

        PR fortran/36825
        PR fortran/36824
        * array.c (gfc_match_array_spec): Fix array-rank check.
        * resolve.c (resolve_fl_derived): Fix constentness check
        for the array dimensions.

2008-07-17  Tobias Burnus  <burnus@net-b.de>

        PR fortran/36825
        PR fortran/36824
        * gfortran.dg/rank_2.f90: Add additional array-rank test.
        * gfortran.dg/array_4.f90: New.


Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/array.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/rank_2.f90

Comment 3 Tobias Burnus 2008-07-17 09:45:21 UTC
Subject: Bug 36824

Author: burnus
Date: Thu Jul 17 09:44:33 2008
New Revision: 137917

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137917
Log:
2008-07-17  Tobias Burnus  <burnus@net-b.de>

        PR fortran/36824
        * resolve.c (resolve_fl_derived): Fix constentness check
        for the array dimensions.

2008-07-17  Tobias Burnus  <burnus@net-b.de>

        PR fortran/36824
        * gfortran.dg/array_4.f90: New.


Added:
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/array_4.f90
Modified:
    branches/gcc-4_3-branch/gcc/fortran/ChangeLog
    branches/gcc-4_3-branch/gcc/fortran/resolve.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

Comment 4 Tobias Burnus 2008-07-17 09:46:25 UTC
FIXED on the trunk (4.4) and for 4.3 (i.e. for 4.3.2).

Thanks for the bugreport.
Comment 5 Tobias Burnus 2008-07-18 13:18:39 UTC
Subject: Bug 36824

Author: burnus
Date: Fri Jul 18 13:17:49 2008
New Revision: 137949

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137949
Log:
The new file gfortran.dg/array_4.f90 was missing from the commit 137910

2008-07-17  Tobias Burnus  <burnus@net-b.de>
        PR fortran/36824
        * gfortran.dg/array_4.f90: New.

Added:
    trunk/gcc/testsuite/gfortran.dg/array_4.f90