Hi all,
first: I am still looking for someone to review my patch at
http://gcc.gnu.org/ml/fortran/2012-01/msg00197.html
* * *
In PR 44857, a patch was added which changed:
= dt_constructor ( character_parameter_array )
to
= dt_constructor ( (/ character(len=n) :: character_parameter_array /) )
if the component had a different length that the PARAMETER of type
character. (Without that change, either out of bound issues occurred or
one the blank padding was missing.)
Unfortunately, the this change was also applied to scalar expressions
such as
= dt_constructor ( character_parameter_array(index) )
which causes an ICE.
The solution is simple: Only do this kind of optimization for arrays.
Build and regtested on x86-64-linux.
OK for the trunk and 4.6?
* * *
Current regression status:
- 8 gfortran regressions (including this one) of which I only regard the
front-end-optimization wong-code issue as serious. One 4.6-only
ice-on-valid-code issue - and 5 other regressions which I regard as of
lesser importance.
- 82 serious regression, 6 P1, 64 P2, 12 P3 - and 108 other regressions
(64 P4 and 54 P5).
Tobias
PS: I think the patch is obvious enough that I will commit it tomorrow,
unless I get an OK today or someone finds a reason why the patch is not
the best solution.
2012-01-24 Tobias Burnus <bur...@net-b.de>
PR fortran/51966
* resolve.c (resolve_structure_cons): Only create an
array constructors for nonscalars.
2012-01-24 Tobias Burnus <bur...@net-b.de>
PR fortran/51966
* gfortran.dg/derived_constructor_char_3.f90: New.
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index c169b9e..b24399d 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -1051,6 +1051,7 @@ resolve_structure_cons (gfc_expr *expr, int init)
&& comp->ts.u.cl->length->expr_type == EXPR_CONSTANT
&& cons->expr->ts.u.cl && cons->expr->ts.u.cl->length
&& cons->expr->ts.u.cl->length->expr_type == EXPR_CONSTANT
+ && cons->expr->rank != 0
&& mpz_cmp (cons->expr->ts.u.cl->length->value.integer,
comp->ts.u.cl->length->value.integer) != 0)
{
--- /dev/null 2012-01-23 08:22:38.999666895 +0100
+++ gcc/gcc/testsuite/gfortran.dg/derived_constructor_char_3.f90 2012-01-24 18:25:51.000000000 +0100
@@ -0,0 +1,30 @@
+! { dg-do compile }
+!
+! PR fortran/51966
+!
+! Contributed by Peter Wind
+!
+
+ type :: Deriv
+ character(len=10) :: name
+ end type
+ character(len=8), dimension(2), parameter :: &
+ DEF_ECOSYSTEMS = (/ "Gridxxxx", "StringYY" /)
+
+ type(Deriv), save :: DepEcoSystem = Deriv(DEF_ECOSYSTEMS(1))
+
+ if (DepEcoSystem%name /= "Gridxxxx" &
+ .or. DepEcoSystem%name(9:9) /= ' ' &
+ .or. DepEcoSystem%name(10:10) /= ' ') call abort()
+ DepEcoSystem%name = 'ABCDEFGHIJ'
+ call Init_EcoSystems()
+ if (DepEcoSystem%name /= "StringYY" &
+ .or. DepEcoSystem%name(9:9) /= ' ' &
+ .or. DepEcoSystem%name(10:10) /= ' ') call abort()
+
+contains
+ subroutine Init_EcoSystems()
+ integer :: i =2
+ DepEcoSystem = Deriv(DEF_ECOSYSTEMS(i))
+ end subroutine Init_EcoSystems
+end