Message ID | ZdB2DPPaQdCCvEpD@tucnak |
---|---|
State | New |
Headers | show |
Series | fortran: gfc_trans_subcomponent_assign fixes [PR113503] | expand |
Hi Jakub, On 2/17/24 10:02, Jakub Jelinek wrote: > Hi! > > The r14-870 changes broke xtb package tests (reduced testcase is the first > one below) and caused ICEs on a test derived from that (the second one). [...] thanks for your detailed analysis and for the patch, which puts things in straight order to actually fix two issues here! > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK for trunk, except for the minor nit below. > --- gcc/testsuite/gfortran.dg/pr113503_1.f90.jj 2024-02-16 14:16:17.937153094 +0100 > +++ gcc/testsuite/gfortran.dg/pr113503_1.f90 2024-02-16 14:16:10.124258815 +0100 > @@ -0,0 +1,18 @@ > +! PR fortran/113503 > +! { dg-do compile } > +! { dg-options "-O2 -fno-inline -Wuninitialized" } > + > +program pr113503 > + implicit none > + type :: T > + character(len=:), allocatable :: u > + end type > + character(len=20) :: us(1) = 'foobar' > + type(T) :: x > + x = T(u = trim (us(1))) ! { dg-bogus "is used uninitialized" } ^^^^ tab here not allowed in Fortran My newsreader shows a tab here, giving a warning when running the test. Also, applying your patch on top of r14-9045 I do not see the uninitialized warning, which could have been fixed by r14-8947. Please recheck and adjust accordingly. > + call foo > +contains > + subroutine foo > + if (x%u /= 'foobar') stop 1 > + end subroutine > +end Thanks, Harald
On Sat, Feb 17, 2024 at 04:05:16PM +0100, Harald Anlauf wrote: > > +program pr113503 > > + implicit none > > + type :: T > > + character(len=:), allocatable :: u > > + end type > > + character(len=20) :: us(1) = 'foobar' > > + type(T) :: x > > + x = T(u = trim (us(1))) ! { dg-bogus "is used uninitialized" } > ^^^^ tab here not allowed in Fortran > > My newsreader shows a tab here, giving a warning when running the test. > Also, applying your patch on top of r14-9045 I do not see the > uninitialized warning, which could have been fixed by r14-8947. > Please recheck and adjust accordingly. I certainly see if I apply just the testsuite part of the patch to current trunk make check-gfortran RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} dg.exp=pr113503*.f90' ... FAIL: gfortran.dg/pr113503_1.f90 -O (test for bogus messages, line 12) FAIL: gfortran.dg/pr113503_2.f90 -O (internal compiler error: in gimplify_var_or_parm_decl, at gimplify.cc:3280) FAIL: gfortran.dg/pr113503_2.f90 -O (test for excess errors) === gfortran Summary for unix/-m32 === # of expected passes 1 # of unexpected failures 3 ... FAIL: gfortran.dg/pr113503_1.f90 -O (test for bogus messages, line 12) FAIL: gfortran.dg/pr113503_2.f90 -O (internal compiler error: in gimplify_var_or_parm_decl, at gimplify.cc:3280) FAIL: gfortran.dg/pr113503_2.f90 -O (test for excess errors) === gfortran Summary for unix/-m64 === # of expected passes 1 # of unexpected failures 3 and that is all gone after I apply the trans-expr.cc patch as well and make before the above command. I have replaced the tab with a space, but from what I can see, there is no warning/error with the options it is compiled, warning with -Wtabs or -Wall and error with -pedantic-errors, but those options aren't used. Thanks. Jakub
--- gcc/fortran/trans-expr.cc.jj 2024-02-14 14:26:19.764810614 +0100 +++ gcc/fortran/trans-expr.cc 2024-02-16 13:58:22.544770967 +0100 @@ -9059,13 +9059,10 @@ alloc_scalar_allocatable_subcomponent (s if (cm->ts.type == BT_CHARACTER && cm->ts.deferred) { gcc_assert (expr2->ts.type == BT_CHARACTER); - if (!expr2->ts.u.cl->backend_decl - || !VAR_P (expr2->ts.u.cl->backend_decl)) - expr2->ts.u.cl->backend_decl = gfc_create_var (TREE_TYPE (slen), - "slen"); - gfc_add_modify (block, expr2->ts.u.cl->backend_decl, slen); - size = expr2->ts.u.cl->backend_decl; + if (!size || !VAR_P (size)) + size = gfc_create_var (TREE_TYPE (slen), "slen"); + gfc_add_modify (block, size, slen); gfc_deferred_strlen (cm, &tmp); lhs_cl_size = fold_build3_loc (input_location, COMPONENT_REF, @@ -9253,19 +9250,20 @@ gfc_trans_subcomponent_assign (tree dest || (cm->ts.type == BT_CLASS && CLASS_DATA (cm)->attr.allocatable && expr->ts.type != BT_CLASS))) { + tree size; + gfc_init_se (&se, NULL); gfc_conv_expr (&se, expr); - tree size; + /* The remainder of these instructions follow the if (cm->attr.pointer) + if (!cm->attr.dimension) part above. */ + gfc_add_block_to_block (&block, &se.pre); /* Take care about non-array allocatable components here. The alloc_* routine below is motivated by the alloc_scalar_allocatable_for_ assignment() routine, but with the realloc portions removed and different input. */ alloc_scalar_allocatable_subcomponent (&block, dest, cm, expr, se.string_length); - /* The remainder of these instructions follow the if (cm->attr.pointer) - if (!cm->attr.dimension) part above. */ - gfc_add_block_to_block (&block, &se.pre); if (expr->symtree && expr->symtree->n.sym->attr.proc_pointer && expr->symtree->n.sym->attr.dummy) --- gcc/testsuite/gfortran.dg/pr113503_1.f90.jj 2024-02-16 14:16:17.937153094 +0100 +++ gcc/testsuite/gfortran.dg/pr113503_1.f90 2024-02-16 14:16:10.124258815 +0100 @@ -0,0 +1,18 @@ +! PR fortran/113503 +! { dg-do compile } +! { dg-options "-O2 -fno-inline -Wuninitialized" } + +program pr113503 + implicit none + type :: T + character(len=:), allocatable :: u + end type + character(len=20) :: us(1) = 'foobar' + type(T) :: x + x = T(u = trim (us(1))) ! { dg-bogus "is used uninitialized" } + call foo +contains + subroutine foo + if (x%u /= 'foobar') stop 1 + end subroutine +end --- gcc/testsuite/gfortran.dg/pr113503_2.f90.jj 2024-02-16 14:17:01.197567699 +0100 +++ gcc/testsuite/gfortran.dg/pr113503_2.f90 2024-02-16 14:16:51.215702778 +0100 @@ -0,0 +1,12 @@ +! PR fortran/113503 +! { dg-do compile } + +program pr113503 + implicit none + type :: T + character(len=:), allocatable :: u + end type + character(len=20) :: us(1) = 'foo' + type(T) :: x + x = T(u = us(1)) +end