This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

More on defined operator/assignment on an abstract type


Janus,

It appears the code I submitted with PR 41556 still gives errors (different
from the previous errors) with gcc 4.5.0 20091106.  The code and error
messages are below.

Damian

$ cat abstract.f03 
module foo_module
  implicit none
  private  ! Hide everything by default
  public :: foo

  type ,abstract :: foo
  contains
    procedure(times_interface) ,deferred :: times
    generic :: operator(*) => times
  end type

  abstract interface
    function times_interface(this,factor) result(product)
      import :: foo
      class(foo) ,intent(in)  :: this
      class(foo) ,allocatable :: product
      real, intent(in) :: factor
    end function 
  end interface

contains

  subroutine scale_this(this,scale)
    class(foo) :: this
    real, intent(in) :: scale
    this = this*scale        ! Preferred implementation
    this = this%times(scale) ! Alternate implementation
  end subroutine

end module
$ /usr/local/gfortran/bin/gfortran-4.5 abstract.f03
abstract.f03:26.4:

    this = this*scale        ! Preferred implementation
    1
Error: Variable must not be polymorphic in assignment at (1)
abstract.f03:27.4:

    this = this%times(scale) ! Alternate implementation
    1
Error: Variable must not be polymorphic in assignment at (1)



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]