[Fortran, (RFC) patch] PR49110/51055 Assignment to alloc. deferred-length character vars

Jakub Jelinek jakub@redhat.com
Tue Dec 18 16:36:00 GMT 2012


On Tue, Dec 18, 2012 at 05:28:09PM +0100, Jakub Jelinek wrote:
> On Tue, Dec 18, 2012 at 04:40:10PM +0100, Tobias Burnus wrote:
> > Looks mostly okay, however, I fear that for
> > 
> > subroutine foo()
> > character(len=:), allocatable :: str
> > allocate(str, stat=istat)
> > end subroutine foo
> > 
> > compiled with "-fno-automatic", gfortran will still generate the
> > non-GFC_PREFIX-mangled string.
> 
> That doesn't compile:
> Error: Allocate-object at (1) with a deferred type parameter requires either a type-spec or SOURCE tag or a MOLD tag
> 
> Where would be TREE_STATIC set on the length variable with -fno-automatic,
> and on which testcase?

subroutine foo(n)
integer :: n
character(len=n + 8), allocatable :: str
allocate(str, stat=istat)
end subroutine foo

compiles with -fno-automatic, but the length var (unlike str var) is clearly
not TREE_STATIC in that case:

        .local  str.1877
        .comm   str.1877,8,8
...
        .uleb128 0x5    # (DIE (0x71) DW_TAG_variable)
        .ascii "str\0"  # DW_AT_name
        .byte   0x1     # DW_AT_decl_file (x.f90)
        .byte   0x3     # DW_AT_decl_line
        .long   0xc2    # DW_AT_type
        .uleb128 0x9    # DW_AT_location
        .byte   0x3     # DW_OP_addr
        .quad   str.1877
        .uleb128 0x6    # (DIE (0x86) DW_TAG_variable)
        .long   .LASF5  # DW_AT_name: ".str"
        .long   0xb6    # DW_AT_type
                        # DW_AT_artificial
        .uleb128 0x2    # DW_AT_location
        .byte   0x91    # DW_OP_fbreg
        .sleb128 -36

(and as can be seen, the dot name makes it through into debug info, but not
assembly outside of DW_AT_name).

	Jakub



More information about the Gcc-patches mailing list