http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55935



--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2013-01-10 
17:35:13 UTC ---

> (note that the test compiles with  -fno-whole-file;-).



To be honest, this is not true for the other failing tests. Reduced

typebound_operator_8.f03



! { dg-do compile }

! PR48946 - complex expressions involving typebound operators of derived types.

!

module field_module

  implicit none

  type ,abstract :: field

  contains

    procedure(field_op_real) ,deferred :: multiply_real

    procedure(field_plus_field) ,deferred :: plus

    generic :: operator(*) => multiply_real

    generic :: operator(+) => plus

  end type

  abstract interface

    function field_plus_field(lhs,rhs)

      import :: field

      class(field) ,intent(in)  :: lhs

      class(field) ,intent(in)  :: rhs

      class(field) ,allocatable :: field_plus_field

    end function

  end interface

  abstract interface

    function field_op_real(lhs,rhs)

      import :: field

      class(field) ,intent(in)  :: lhs

      real ,intent(in) :: rhs

      class(field) ,allocatable :: field_op_real

    end function

  end interface

end module



module i_field_module

  use field_module

  implicit none

  type, extends (field)  :: i_field

    integer :: i

  contains

    procedure :: multiply_real => i_multiply_real

    procedure :: plus => i_plus_i

  end type

contains

  function i_plus_i(lhs,rhs)

    class(i_field) ,intent(in)  :: lhs

    class(field) ,intent(in)  :: rhs

    class(field) ,allocatable :: i_plus_i

    integer :: m = 0

    select type (lhs)

      type is (i_field); m = lhs%i

    end select

    select type (rhs)

      type is (i_field); m = rhs%i + m

    end select

    allocate (i_plus_i, source = i_field (m))

  end function

  function i_multiply_real(lhs,rhs)

    class(i_field) ,intent(in)  :: lhs

    real ,intent(in) :: rhs

    class(field) ,allocatable :: i_multiply_real

    integer :: m = 0

    select type (lhs)

      type is (i_field); m = lhs%i * int (rhs)

    end select

    allocate (i_multiply_real, source = i_field (m))

  end function

end module



This test compiles if I comment one of the ALLOCATE.

Reply via email to