Select type on pointer
Janus Weil
janus@gcc.gnu.org
Wed Nov 25 09:11:00 GMT 2009
Hi Damian,
> The following code produces the error message below it.
thanks for reporting this. I can reproduce the behavior that you see.
Could you file a PR?
> It appears gfortran thinks 'total' is a function.
Well, yeah, after all it is a function, right? ;)
Of course inside the function body 'total' should refer to the return
value, so the error message that you get is clearly a bug. An obvious
workaround is to use an explicit result variable.
I will take care of this ...
Cheers,
Janus
> $ cat select_type.f03
> module bar_module
> implicit none
> type :: bar
> real ,dimension(:) ,allocatable :: f
> contains
> procedure :: total
> end type
>
> contains
>
> function total(lhs,rhs)
> class(bar) ,intent(in) :: lhs
> class(bar) ,intent(in) :: rhs
> class(bar) ,pointer :: total
> select type(rhs)
> type is (bar)
> allocate(bar :: total)
> select type(total)
> type is (bar)
> total%f = lhs%f + rhs%f
> end select
> end select
> end function
>
> $ gfortran -c select_type.f03
> select_type.f03:18.25:
>
> select type(total)
> 1
> Error: Function 'total' requires an argument list at (1)
> select_type.f03:20.17:
>
> total%f = lhs%f + rhs%f
> 1
> Error: 'total' at (1) is not a variable
> select_type.f03:22.7:
>
> end select
> 1
> Error: Expecting END FUNCTION statement at (1)
>
>
>
More information about the Fortran
mailing list