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]

Re: gfortran accepting a target as pointer initialization espression


2015-03-05 10:33 GMT+0100, marco restelli <mrestelli@gmail.com>:
> 2015-03-05 10:13 GMT+0100, Janus Weil <janus@gcc.gnu.org>:
>> Hi Marco,
>>
>> this kind of pointer initialization is an F08 feature, and I think
>> gfortran is right in accepting it according to the F08 standard.
>>
>> Note that it is being rejected when you ask for F03:
>>
>> $ gfortran -c test.f90 -std=f2003
>> test.f90:6.25:
>>
>>  real, pointer :: pr => r
>>                          1
>> Error: Fortran 2008: non-NULL pointer initialization at (1)
>
> Nice!
>
> (Sorry, I only tried with f2008 and did not think about changing that)
>
> Is this what is described by "null-init" and "initial-data-target", in
> R505 of the standard (section 5.2.1)?
>
> nitialization is = constant-expr
>               or => null-init
>               or => initial-data-target
>
> Then I have a follow-up question: gfortran refuses the following code
>
>
> module m1
>  implicit none
>
> contains
>  pure function f(x) result(y)
>   real, intent(in) :: x
>   real :: y
>    y = 2.0*x
>  end function f
> end module m1
>
>
> module m2
>  use m1
>  implicit none
>
>  type :: t
>   procedure(f), pointer, nopass :: p => null()
>  end type t
>
>  type(t) :: var_t = t(f)
> end module m2
>
>
>
> gfortran -std=f2008 -c pnt.f90 -o pnt.o
> pnt.f90:21:22:
>
>   type(t) :: var_t = t(f)
>                       1
> Error: Parameter »f« at (1) has not been declared or is a variable,
> which does not reduce to a constant expression
>
>
> Is this also valid f2008 or not?

Hi again,
   another doubt along the same line. I see that the following code is
accepted (with f2008):


module m1
 implicit none

contains
 pure function f(x) result(y)
  real, intent(in) :: x
  real :: y
   y = 2.0*x
 end function f
end module m1


module m2
 use m1
 implicit none

 procedure(f), pointer :: pf => f
end module m2


Isn't this a contradiction of

R506 null-init is function-reference
[...]
C512 (R506) The function-reference shall be a reference to the
intrinsic function NULL with no arguments.


Marco


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