Bug 51977

Summary: [OOP] MOVE_ALLOC: Bogus "must have the same rank 0/1" for same-rank arrays
Product: gcc Reporter: Tobias Burnus <burnus>
Component: fortranAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: burnus, janus
Priority: P3 Keywords: rejects-valid
Version: 4.7.0   
Target Milestone: 4.7.0   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:

Description Tobias Burnus 2012-01-24 08:11:55 UTC
Split off from PR 51948.

The following fails at move_alloc with a bogus error:

  Error: the 'from' and 'to' arguments of 'move_alloc'  intrinsic at (1)
         must have the same rank 0/1


type t
end type t

contains
  function func(x)
    class(t), allocatable :: x(:), func(:)
    call move_alloc (x, func)
  end function
end
Comment 1 Tobias Burnus 2012-01-24 15:29:02 UTC
See also PR 51970, which has a similar issue - and contains a fix for the follow-up issue (trans-intrinsic.c's conv_intrinsic_move_alloc).
Comment 2 Tobias Burnus 2012-01-27 13:08:58 UTC
Author: burnus
Date: Fri Jan 27 13:08:52 2012
New Revision: 183622

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

        PR fortran/51970
        PR fortran/51977
        * primary.c (gfc_match_varspec. gfc_match_rvalue): Set
        handle array spec for BT_CLASS.
        * expr.c (gfc_get_variable_expr, gfc_lval_expr_from_sym)
        * frontend-passes.c (create_var): Ditto.
        * resolve.c (resolve_actual_arglist, resolve_assoc_var): Ditto.
        * trans-decl.c (gfc_trans_deferred_vars): Use class_pointer
        instead of attr.pointer.
        (gfc_generate_function_code): Use CLASS_DATA (sym) for BT_CLASS.
        * trans-intrinsic.c (conv_intrinsic_move_alloc): Move assert.
        * trans-stmt.c (trans_associate_var): Ask for the descriptor.

2012-01-27  Tobias Burnus  <burnus@net-b.de>

        PR fortran/51970
        PR fortran/51977
        * gfortran.dg/move_alloc_13.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/move_alloc_13.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/expr.c
    trunk/gcc/fortran/frontend-passes.c
    trunk/gcc/fortran/primary.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/fortran/trans-intrinsic.c
    trunk/gcc/fortran/trans-stmt.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 Tobias Burnus 2012-01-27 13:10:00 UTC
FIXED on the trunk (4.7).