https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70937

--- Comment #12 from rguenther at suse dot de <rguenther at suse dot de> ---
On Fri, 6 May 2016, Richard Biener wrote:

> On Fri, 6 May 2016, dominiq at lps dot ens.fr wrote:
> 
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70937
> > 
> > --- Comment #10 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> > With the second patch in comment 9 applied on top of my working tree 
> > (heavily
> > patched), I get
> > 
> > [Book15] f90/bug% gfc
> > /opt/gcc/_clean/gcc/testsuite/gfortran.dg/allocatable_function_4.f90
> > -fdump-tree-original
> > /opt/gcc/_clean/gcc/testsuite/gfortran.dg/allocatable_function_4.f90:52:0:
> > 
> >  end function unique_A
> > 
> > internal compiler error: tree check: expected tree that contains 'decl 
> > common'
> > structure, have 'identifier_node' in print_declaration, at
> > tree-pretty-print.c:3287
> 
> Which means TYPE_NAME is an IDENTIFIER_NODE here.
> 
> Index: gcc/fortran/trans-decl.c
> ===================================================================
> --- gcc/fortran/trans-decl.c    (revision 235945)
> +++ gcc/fortran/trans-decl.c    (working copy)
> @@ -3818,6 +3818,12 @@ gfc_trans_vla_type_sizes (gfc_symbol *sy
>      }
>  
>    gfc_trans_vla_type_sizes_1 (type, body);
> +  /* gfc_build_qualified_array may have built this type but left 
> TYPE_NAME
> +     pointing to the original type whose type sizes we need to expose to
> +     the gimplifier unsharing.  */
> +  if (TYPE_NAME (type)
> +      && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
> +    gfc_add_expr_to_block (body, build1 (DECL_EXPR, type, TYPE_NAME 
> (type)));
>  }
>  
>  
> 
> fixes this.  I'm going to re-test with that change, will not be able
> to commit before Monday.

Interestingly even with that I still at least get

FAIL: libgomp.fortran/vla7.f90   -O0  execution test
FAIL: libgomp.fortran/vla7.f90   -O1  execution test
FAIL: libgomp.fortran/vla7.f90   -O2  execution test
FAIL: libgomp.fortran/vla7.f90   -O3 -fomit-frame-pointer -funroll-loops 
-fpeel-loops -ftracer -finline-functions  execution test
FAIL: libgomp.fortran/vla7.f90   -O3 -g  execution test
FAIL: libgomp.fortran/vla7.f90   -Os  execution test

I wonder if it would be better to simply _not_ use the "old" type
when building the TYPE_DECL for the restrict array type...

Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c    (revision 235945)
+++ gcc/fortran/trans-decl.c    (working copy)
@@ -1004,8 +1004,8 @@ gfc_build_qualified_array (tree decl, gf
            }
        }
       TYPE_NAME (type) = type_decl = build_decl (input_location,
-                                                TYPE_DECL, NULL, gtype);
-      DECL_ORIGINAL_TYPE (type_decl) = gtype;
+                                                TYPE_DECL, NULL, type);
+      DECL_ORIGINAL_TYPE (type_decl) = type;
     }
 }

this also fixes the original testcase but it seems that was done on
purpose for debug info in r139774 (by Jakub again).

As for the execute fail it looks like the place of the DECL_EXPR
is wrong (just guessing here).

Reply via email to