Steve did the digging on another of Gerhard's "torture tests" involving
NULL() arguments to intrinsics.  I have mainly cleaned up his patch and
packaged and regtested on x86_64-pc-linux-gnu.

OK for master?

Thanks,
Harald


PR fortran/95544 - Fix ICE in NULL() argument to intrinsics

Fortran 2018: An argument to an intrinsic procedure other than ASSOCIATED,
NULL, or PRESENT shall be a data object.  An EXPR_NULL is not a data
object.  Add checks for intrinsics.

2020-06-08  Steven G. Kargl  <ka...@gcc.gnu.org>
            Harald Anlauf  <anl...@gmx.de>

gcc/fortran/
        PR fortran/95544
        * check.c (invalid_null_arg): Rename to gfc_invalid_null_arg.
        (gfc_check_associated, gfc_check_kind, gfc_check_merge)
        (gfc_check_shape, gfc_check_size, gfc_check_spread)
        (gfc_check_transfer): Adjust.
        (gfc_check_len_lentrim, gfc_check_trim): Check for NULL() argument.
        * gfortran.h: Declare gfc_invalid_null_arg ().
        * intrinsic.c (check_arglist): Check for NULL() argument.

! { dg-do compile }
! PR fortran/95544 - ICE in gfc_can_put_var_on_stack, at fortran/trans-decl.c:494

program test
   character(:), allocatable :: z
   character(:), pointer     :: p
   character(1), pointer     :: c
   print *, adjustl (null(z)) ! { dg-error "is not permitted as actual argument" }
   print *, adjustr (null(z)) ! { dg-error "is not permitted as actual argument" }
   print *, len     (null(p)) ! { dg-error "is not permitted as actual argument" }
   print *, len     (null(z)) ! { dg-error "is not permitted as actual argument" }
   print *, len_trim(null(c)) ! { dg-error "is not permitted as actual argument" }
   print *, len_trim(null(z)) ! { dg-error "is not permitted as actual argument" }
   print *, trim    (null(z)) ! { dg-error "is not permitted as actual argument" }
end

Reply via email to