Bug 53329 - ICE with deferred-length module variables
ICE with deferred-length module variables
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: fortran
4.8.0
: P3 normal
: ---
Assigned To: Not yet assigned to anyone
: ice-on-valid-code
Depends on:
Blocks: 45170
  Show dependency treegraph
 
Reported: 2012-05-12 10:35 UTC by Tobias Burnus
Modified: 2012-05-14 16: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 Tobias Burnus 2012-05-12 10:35:54 UTC
The following code gives an ICE:

  module m
    character(len=:), allocatable :: str
  end module m

Untested fix:

--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -1103,2 +1103,10 @@ gfc_create_string_length (gfc_symbol * sym)
       sym->ts.u.cl->backend_decl = length;
+
+      if (sym->attr.save
+         || (ns->parent && ns->parent->proc_name->attr.flavor == FL_MODULE))
+       TREE_STATIC (length) = 1;
+
+      if (ns->parent && ns->parent->proc_name->attr.flavor == FL_MODULE
+         && (sym->attr.access != ACCESS_PRIVATE || sym->attr.public_used))
+       TREE_PUBLIC (length) = 1;
     }
Comment 1 Tobias Burnus 2012-05-14 16:45:32 UTC
Author: burnus
Date: Mon May 14 16:45:16 2012
New Revision: 187472

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187472
Log:
2012-05-14  Tobias Burnus  <burnus@net-b.de>

        PR fortran/49110
        PR fortran/51055
        PR fortran/53329
        * trans-expr.c (gfc_trans_assignment_1): Fix allocation
        handling for assignment of function results to allocatable
        deferred-length strings.
        * trans-decl.c (gfc_create_string_length): For deferred-length
        module variables, include module name in the assembler name.
        (gfc_get_symbol_decl): Don't override the assembler name.

2012-05-14  Tobias Burnus  <burnus@net-b.de>

        PR fortran/49110
        PR fortran/51055
        PR fortran/53329
        * gfortran.dg/deferred_type_param_4.f90: New.
        * gfortran.dg/deferred_type_param_6.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/deferred_type_param_4.f90
    trunk/gcc/testsuite/gfortran.dg/deferred_type_param_6.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/testsuite/ChangeLog
Comment 2 Tobias Burnus 2012-05-14 16:46:14 UTC
FIXED on the trunk (4.8).