diff mbox

[fortran] PR 49074 ICE on defined assignment with class arrays.

Message ID 51BC86D1.5040005@sfr.fr
State New
Headers show

Commit Message

Mikael Morin June 15, 2013, 3:22 p.m. UTC
Hello,

Dominique noticed that the patch also fixed PR56136 whose test is very
close to the one of PR49074.
This made me notice that while the PR56136 test should use a temporary
(and does), the PR49074 one shouldn't.  That is fixed with the attached
patch.
Then the ICE which was fixed by the previous patch isn't
reachable any more in the PR49074 test-case, so I also add a test
based on the PR56136 one.

Regression tested on x86_64-unknown-linux-gnu.  OK for trunk?

Mikael
2013-06-15  Mikael Morin  <mikael@gcc.gnu.org>

	PR fortran/49074
	PR fortran/56136
	* dependency.c (gfc_check_argument_var_dependency): Return 0 in the
	array constructor case.

2013-06-15  Mikael Morin  <mikael@gcc.gnu.org>

	PR fortran/49074
	PR fortran/56136
	* gfortran.dg/typebound_assignment_5.f03: Check the absence of any packing.
	* gfortran.dg/typebound_assignment_6.f03: New.
Index: typebound_assignment_5.f03
===================================================================
--- typebound_assignment_5.f03	(révision 200070)
+++ typebound_assignment_5.f03	(copie de travail)
@@ -1,4 +1,5 @@
 ! { dg-do run }
+! { dg-options "-fdump-tree-original" }
 !
 ! PR fortran/49074
 ! ICE on defined assignment with class arrays.
@@ -38,3 +39,6 @@
         if (any(foobar%i /= [1, 2])) call abort
       end program
 
+! { dg-final { scan-tree-dump-not "_gfortran_internal_pack" "original" } }
+! { dg-final { scan-tree-dump-not "_gfortran_internal_unpack" "original" } }
+! { dg-final { cleanup-tree-dump "original"} }
! { dg-do run }
! { dg-options "-fdump-tree-original" }
!
! PR fortran/56136
! ICE on defined assignment with class arrays.
!
! Original testcase by Alipasha <alipash.celeris@gmail.com>

      MODULE A_TEST_M
        TYPE :: A_TYPE
          INTEGER :: I
          CONTAINS
          GENERIC :: ASSIGNMENT (=) => ASGN_A
          PROCEDURE, PRIVATE :: ASGN_A
        END TYPE

        CONTAINS

        ELEMENTAL SUBROUTINE ASGN_A (A, B)
          CLASS (A_TYPE), INTENT (INOUT) :: A
          CLASS (A_TYPE), INTENT (IN) :: B
          A%I = B%I
        END SUBROUTINE
      END MODULE A_TEST_M
      
      PROGRAM ASGN_REALLOC_TEST
        USE A_TEST_M
        TYPE (A_TYPE), ALLOCATABLE :: A(:)
        INTEGER :: I, J

        ALLOCATE (A(100))
        A = (/ (A_TYPE(I), I=1,SIZE(A)) /)
        A(1:50) = A(51:100)
        IF (ANY(A%I /= (/ ((50+I, I=1,SIZE(A)/2), J=1,2) /))) CALL ABORT
        A(::2) = A(1:50)        ! pack/unpack
        IF (ANY(A( ::2)%I /= (/ (50+I, I=1,SIZE(A)/2) /))) CALL ABORT  
        IF (ANY(A(2::2)%I /= (/ ((50+2*I, I=1,SIZE(A)/4), J=1,2) /))) CALL ABORT  
      END PROGRAM

! { dg-final { scan-tree-dump-times "_gfortran_internal_pack" 1 "original" } }
! { dg-final { scan-tree-dump-times "_gfortran_internal_unpack" 1 "original" } }
! { dg-final { cleanup-tree-dump "original" } }

Comments

Tobias Burnus June 15, 2013, 4 p.m. UTC | #1
Mikael Morin wrote:
> Dominique noticed that the patch also fixed PR56136 whose test is very
> close to the one of PR49074.
> This made me notice that while the PR56136 test should use a temporary
> (and does), the PR49074 one shouldn't.  That is fixed with the attached
> patch.
> Then the ICE which was fixed by the previous patch isn't
> reachable any more in the PR49074 test-case, so I also add a test
> based on the PR56136 one.
>
> Regression tested on x86_64-unknown-linux-gnu.  OK for trunk?

OK. Thanks to the patch - and for voiding the temporary.

Tobias

PS: Pending patch:Print exception status at STOP, 
http://gcc.gnu.org/ml/fortran/2013-06/msg00077.html
diff mbox

Patch

Index: dependency.c
===================================================================
--- dependency.c	(révision 200067)
+++ dependency.c	(copie de travail)
@@ -990,7 +990,9 @@  gfc_check_argument_var_dependency (gfc_expr *var,
       return 0;
 
     case EXPR_ARRAY:
-      return gfc_check_dependency (var, expr, 1);
+      /* the scalarizer always generates a temporary for array constructors,
+	 so there is no dependency.  */
+      return 0;
 
     case EXPR_FUNCTION:
       if (intent != INTENT_IN)