Hello

Le 04/10/2022 à 21:27, Harald Anlauf via Fortran a écrit :
Dear all,

when looking at output item lists we didn't catch procedures
and procedure pointers and ran into a gfc_internal_error().
Such items are not allowed by the Fortran standard, e.g. for
procedure pointers there is

C1233 (R1217) An expression that is an output-item shall not
               have a value that is a procedure pointer.

Attached patch generates an error instead.

Regtested on x86_64-pc-linux-gnu.  OK for mainline?

Please move the check to resolve_transfer in resolve.cc.

Strangely, the patch doesn't seem to fix the problem on the testcase here. There is an outer parenthese expression preventing the condition you added from triggering. Can you double check?

If we take the standard to the letter, only output items are forbidden, so a check is missing for writing context. I don't know how it can work for input items though, so maybe not worth it. In any case, the error shouldn't mention output items in reading context.

Here is a variant of the testcase with procedure pointer components, that fails differently but can probably be caught as well.

program p
  implicit none
  type :: t
    procedure(f), pointer, nopass :: b
  end type t
  type(t) :: a

  interface
    real function f()
    end function f
  end interface

  print *, merge (a%b, a%b, .true.)
end


Reply via email to