aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/used_before_typed_1.f90
blob: 972a16742989193970ad2c2e7f17d9ea852ee09b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
! { dg-do compile }
! { dg-options "-std=f95" }

! PR fortran/32095
! PR fortran/34228
! Check that standards-conforming mode rejects uses of variables that
! are used before they are typed.

SUBROUTINE test1 (n, arr, m, arr2, k, arr3, a) ! { dg-error "has no IMPLICIT" }
  IMPLICIT NONE

  INTEGER :: arr(n) ! { dg-error "used before it is typed" }
  INTEGER :: n
  INTEGER :: m, arr2(m) ! { dg-bogus "used before it is typed" }
  INTEGER, DIMENSION(k) :: arr3 ! { dg-error "used before it is typed" }
  INTEGER :: k
  CHARACTER(len=LEN(a)) :: a ! { dg-error "'a' is used before it is typed" }

  REAL(KIND=l) :: x ! { dg-error "has no IMPLICIT type" }
  REAL(KIND=KIND(y)) :: y ! { dg-error "has no IMPLICIT type" }

  DATA str/'abc'/ ! { dg-error "used before it is typed" }
  CHARACTER(len=3) :: str, str2
  DATA str2/'abc'/ ! { dg-bogus "used before it is typed" }
END SUBROUTINE test1

SUBROUTINE test2 (n, arr, m, arr2)
  IMPLICIT INTEGER(a-z)

  INTEGER :: arr(n)
  REAL :: n ! { dg-error "already has basic type" }
  INTEGER :: m, arr2(m) ! { dg-bogus "already has an IMPLICIT type" }
END SUBROUTINE test2

SUBROUTINE test3 (n, arr, m, arr2)
  IMPLICIT REAL(a-z)

  INTEGER :: arr(n) ! { dg-error "must be of INTEGER type" }
  INTEGER :: m, arr2(m) ! { dg-bogus "must be of INTEGER type" }
END SUBROUTINE test3