I have now committed (Rev. 202725) a test case for that patch. (I
confirmed that it fails before Rev. 202609 and works now.)
See attachment.
(While trying to create a test case, I found another bug with defined
assignment; see PR fortran/58469.)
Tobias
PS: I still have to do the backporting to 4.8. By the way, the following
patch is still pending to be reviewed:
http://gcc.gnu.org/ml/fortran/2013-09/msg00031.html
Thomas Koenig wrote:
As testing showed, it didn't fix the real-world code: ForTrilinos's
ForTrilinos_ADT_3D_Burgers_6th_Pade did still fail as it has:
*_F.DA65 = matrix_diff_x (&parm.621);
_F.DA66 = ax->epetra_rowmatrix.universal; // Deref of "ax"!
Build and regtested on x86-64-gnu-linux.
OK?
The patch is OK, also for 4.8. Please add a test case which also
checks for the ForTrilinos failure.
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (Revision 202724)
+++ gcc/testsuite/ChangeLog (Arbeitskopie)
@@ -1,3 +1,8 @@
+2013-09-18 Tobias Burnus <bur...@net-b.de>
+
+ PR fortran/57697
+ * gfortran.dg/defined_assignment_11.f90: New.
+
2013-09-18 Vladimir Makarov <vmaka...@redhat.com>
PR rtl-optimization/58438
Index: gcc/testsuite/gfortran.dg/defined_assignment_11.f90
===================================================================
--- gcc/testsuite/gfortran.dg/defined_assignment_11.f90 (Revision 0)
+++ gcc/testsuite/gfortran.dg/defined_assignment_11.f90 (Arbeitskopie)
@@ -0,0 +1,43 @@
+! { dg-do run }
+!
+! PR fortran/57697
+!
+! Further test of typebound defined assignment
+!
+module m0
+ implicit none
+ type :: component
+ integer :: i = 42
+ integer, allocatable :: b
+ contains
+ procedure :: assign0
+ generic :: assignment(=) => assign0
+ end type
+ type, extends(component) :: comp2
+ real :: aa
+ end type comp2
+ type parent
+ type(component) :: foo
+ real :: cc
+ end type
+ type p2
+ type(parent) :: x
+ end type p2
+contains
+ elemental subroutine assign0(lhs,rhs)
+ class(component), intent(INout) :: lhs
+ class(component), intent(in) :: rhs
+ lhs%i = 20
+ end subroutine
+end module
+
+program main
+ use m0
+ implicit none
+ type(p2), allocatable :: left
+ type(p2) :: right
+! print *, right%x%foo%i
+ left = right
+! print *, left%x%foo%i
+ if (left%x%foo%i /= 20) call abort()
+end