view gcc/testsuite/gfortran.dg/bounds_check_strlen_2.f90 @ 144:8f4e72ab4e11

fix segmentation fault caused by nothing next cur_op to end
author Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sun, 23 Dec 2018 21:23:56 +0900
parents 04ced10e8804
children
line wrap: on
line source

! { dg-do run }
! { dg-options "-fbounds-check" }
! { dg-shouldfail "Character length mismatch" }

! PR fortran/37746
! Test bounds-checking for string length of dummy arguments.

MODULE m

CONTAINS

  SUBROUTINE test (str, n)
    IMPLICIT NONE
    INTEGER :: n
    CHARACTER(len=n) :: str
  END SUBROUTINE test

  SUBROUTINE test2 (str)
    IMPLICIT NONE
    CHARACTER(len=*) :: str
    CALL test (str, 5) ! Expected length of str is 5.
  END SUBROUTINE test2

END MODULE m

PROGRAM main
  USE m
  IMPLICIT NONE
  CALL test2 ('abc') ! String is too short.
END PROGRAM main

! { dg-output "shorter than the declared one for dummy argument 'str' \\(3/5\\)" }