OSDN Git Service

2010-06-18 Jerry DeLisle <jvdelisle@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / bounds_check_strlen_2.f90
1 ! { dg-do run }
2 ! { dg-options "-fbounds-check" }
3 ! { dg-shouldfail "Character length mismatch" }
4
5 ! PR fortran/37746
6 ! Test bounds-checking for string length of dummy arguments.
7
8 MODULE m
9
10 CONTAINS
11
12   SUBROUTINE test (str, n)
13     IMPLICIT NONE
14     CHARACTER(len=n) :: str
15     INTEGER :: n
16   END SUBROUTINE test
17
18   SUBROUTINE test2 (str)
19     IMPLICIT NONE
20     CHARACTER(len=*) :: str
21     CALL test (str, 5) ! Expected length of str is 5.
22   END SUBROUTINE test2
23
24 END MODULE m
25
26 PROGRAM main
27   USE m
28   IMPLICIT NONE
29   CALL test2 ('abc') ! String is too short.
30 END PROGRAM main
31
32 ! { dg-output "shorter than the declared one for dummy argument 'str' \\(3/5\\)" }
33 ! { dg-final { cleanup-modules "m" } }