PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gfortran.dg / trim_1.f90
blob99ae550082efc3407c41f97739f13359dcbb74c6
1 ! { dg-do run }
3 ! Torture-test TRIM and LEN_TRIM for correctness.
6 ! Given a total string length and a trimmed length, construct an
7 ! appropriate string and check gfortran gets it right.
9 SUBROUTINE check_trim (full_len, trimmed_len)
10 IMPLICIT NONE
11 INTEGER, INTENT(IN) :: full_len, trimmed_len
12 CHARACTER(LEN=full_len) :: string
14 string = ""
15 IF (trimmed_len > 0) THEN
16 string(trimmed_len:trimmed_len) = "x"
17 END IF
19 IF (LEN (string) /= full_len &
20 .OR. LEN_TRIM (string) /= trimmed_len &
21 .OR. LEN (TRIM (string)) /= trimmed_len &
22 .OR. TRIM (string) /= string (1:trimmed_len)) THEN
23 PRINT *, full_len, trimmed_len
24 PRINT *, LEN (string), LEN_TRIM (string)
25 STOP 1
26 END IF
27 END SUBROUTINE check_trim
30 ! The main program, check with various combinations.
32 PROGRAM main
33 IMPLICIT NONE
34 INTEGER :: i, j
36 DO i = 0, 20
37 DO j = 0, i
38 CALL check_trim (i, j)
39 END DO
40 END DO
41 END PROGRAM main