summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/fmt_error_3.f90
blob: 257f876ed80de482cc54cbde2bdeceecd98155fc (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
! { dg-do compile }

! PR fortran/29835
! Check for improved format error messages with correct locus and more detailed
! "unexpected element" messages.

SUBROUTINE format_labels
  IMPLICIT NONE

1 FORMAT (A, &
          A, &
          Q, & ! { dg-error "Unexpected element 'Q'" }
          A)

2 FORMAT (A, &
          I, & ! { dg-error "Nonnegative width" }
          A)

END SUBROUTINE format_labels

SUBROUTINE format_strings
  IMPLICIT NONE
  CHARACTER(len=32), PARAMETER :: str = "hello"
  INTEGER :: x

  PRINT '(A, Q, A)', & ! { dg-error "Unexpected element 'Q'" }
        str, str, str ! { dg-bogus "Unexpected element" }

  PRINT '(A, ' // & ! { dg-error "Nonnegative width" }
        ' I, ' // &
        ' A)', str, str, str ! { dg-bogus "Nonnegative width" }

  READ '(Q)', & ! { dg-error "Unexpected element 'Q'" }
       x ! { dg-bogus "Unexpected element" }

END SUBROUTINE format_strings