Hi Steve,
I moved too quickly and caused a regression. See the link in the
testcase. The attached fixes the problem and bootstraps/regtests.
OK for trunk?
Paul
On 5 November 2016 at 16:17, Steve Kargl
<[email protected]> wrote:
> On Sat, Nov 05, 2016 at 10:05:30AM +0100, Paul Richard Thomas wrote:
>>
>> Bootstraps and regtests on FC21/x86_64 - OK for trunk?
>
> OK with minor nit (see below).
>
>>
>> + /* F2003 12.4.1.7 */
>> + if (to->expr_type == EXPR_VARIABLE && from->expr_type ==EXPR_VARIABLE
>
> Need a space after ==.
>
> --
> Steve
--
The difference between genius and stupidity is; genius has its limits.
Albert Einstein
Index: gcc/fortran/check.c
===================================================================
*** gcc/fortran/check.c (revision 241872)
--- gcc/fortran/check.c (working copy)
*************** gfc_check_move_alloc (gfc_expr *from, gf
*** 3343,3355 ****
}
/* F2003 12.4.1.7 */
! if (to->expr_type == EXPR_VARIABLE && from->expr_type ==EXPR_VARIABLE
&& !strcmp (to->symtree->n.sym->name, from->symtree->n.sym->name))
{
! gfc_error ("The FROM and TO arguments at %L are either the same object "
! "or subobjects thereof and so violate aliasing restrictions "
! "(F2003 12.4.1.7)", &to->where);
! return false;
}
/* CLASS arguments: Make sure the vtab of from is present. */
--- 3343,3380 ----
}
/* F2003 12.4.1.7 */
! if (to->expr_type == EXPR_VARIABLE && from->expr_type == EXPR_VARIABLE
&& !strcmp (to->symtree->n.sym->name, from->symtree->n.sym->name))
{
! gfc_ref *to_ref, *from_ref;
! to_ref = to->ref;
! from_ref = from->ref;
! bool aliasing = true;
!
! for (; from_ref && to_ref;
! from_ref = from_ref->next, to_ref = to_ref->next)
! {
! if (to_ref->type != from->ref->type)
! aliasing = false;
! else if (to_ref->type == REF_ARRAY
! && to_ref->u.ar.type != AR_FULL
! && from_ref->u.ar.type != AR_FULL)
! /* Play safe; assume sections and elements are different. */
! aliasing = false;
! else if (to_ref->type == REF_COMPONENT
! && to_ref->u.c.component != from_ref->u.c.component)
! aliasing = false;
!
! if (!aliasing)
! break;
! }
!
! if (aliasing)
! {
! gfc_error ("The FROM and TO arguments at %L violate aliasing "
! "restrictions (F2003 12.4.1.7)", &to->where);
! return false;
! }
}
/* CLASS arguments: Make sure the vtab of from is present. */
Index: gcc/testsuite/gfortran.dg/move_alloc_18.f90
===================================================================
*** gcc/testsuite/gfortran.dg/move_alloc_18.f90 (revision 0)
--- gcc/testsuite/gfortran.dg/move_alloc_18.f90 (working copy)
***************
*** 0 ****
--- 1,21 ----
+ ! { dg-do compile }
+ !
+ ! Test that the anti-aliasing restriction does not knock out valid code.
+ !
+ ! Contributed by Andrew Balwin on
+ ! https://groups.google.com/forum/#!topic/comp.lang.fortran/oiXdl1LPb_s
+ !
+ PROGRAM TEST
+ IMPLICIT NONE
+
+ TYPE FOOBAR
+ INTEGER, ALLOCATABLE :: COMP(:)
+ END TYPE
+
+ TYPE (FOOBAR) :: MY_ARRAY(6)
+
+ ALLOCATE (MY_ARRAY(1)%COMP(10))
+
+ CALL MOVE_ALLOC (MY_ARRAY(1)%COMP, MY_ARRAY(2)%COMP)
+
+ END PROGRAM TEST