On Wed, Dec 14, 2016 at 11:55 PM, Jakub Jelinek <ja...@redhat.com> wrote: > Hi! > > The gimplifier (because of Ada :( ) doesn't recurse to POINTER_TYPE's > type when gimplifying types, so we need a DECL_EXPR to gimplify such > types if they are VLAs. The following patch is an attempt to do that. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
Ok, but could you name the testcase something more descriptive, say, char_result_16.f90? > > 2016-12-14 Jakub Jelinek <ja...@redhat.com> > > PR fortran/78757 > * trans-expr.c (gfc_conv_procedure_call): Emit DECL_EXPR for the > type pstr var points to. > > * gfortran.dg/pr78757.f90: New test. > > --- gcc/fortran/trans-expr.c.jj 2016-12-09 20:32:39.000000000 +0100 > +++ gcc/fortran/trans-expr.c 2016-12-14 15:22:50.142968565 +0100 > @@ -6009,6 +6009,19 @@ gfc_conv_procedure_call (gfc_se * se, gf > { > var = gfc_create_var (type, "pstr"); > > + /* Emit a DECL_EXPR for the VLA type. */ > + tmp = TREE_TYPE (type); > + if (TYPE_SIZE (tmp) > + && TREE_CODE (TYPE_SIZE (tmp)) != INTEGER_CST) > + { > + tmp = build_decl (input_location, TYPE_DECL, NULL_TREE, > tmp); > + DECL_ARTIFICIAL (tmp) = 1; > + DECL_IGNORED_P (tmp) = 1; > + tmp = fold_build1_loc (input_location, DECL_EXPR, > + TREE_TYPE (tmp), tmp); > + gfc_add_expr_to_block (&se->pre, tmp); > + } > + > if ((!comp && sym->attr.allocatable) > || (comp && comp->attr.allocatable)) > { > --- gcc/testsuite/gfortran.dg/pr78757.f90.jj 2016-12-14 15:28:09.707932278 > +0100 > +++ gcc/testsuite/gfortran.dg/pr78757.f90 2016-12-14 15:27:54.000000000 > +0100 > @@ -0,0 +1,16 @@ > +! PR fortran/78757 > +! { dg-do compile } > +! { dg-options "-O1" } > + > +program pr78757 > + implicit none > + character (len = 30), target :: x > + character (len = 30), pointer :: s > + s => foo (70_8) > +contains > + function foo (i) > + integer (8) :: i > + character (len = i), pointer :: foo > + foo => x > + end function foo > +end program pr78757 > > Jakub -- Janne Blomqvist