xref: /llvm-project/flang/test/Semantics/error_stop1a.f90 (revision 52601325f1a4db06510dbe12562240a018a254bd)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2! This test checks for semantic errors in error stop statements based on the
3! statement specification in section 11.4 of the Fortran 2018 standard.
4
5program test_error_stop
6  implicit none
7
8  integer int_code, int_array(1), int_coarray[*], array_coarray(1)[*]
9  integer(kind=1) non_default_int_kind
10  character(len=128) char_code, char_array(1), char_coarray[*], non_logical
11  character(kind=4, len=128) non_default_char_kind
12  logical bool, logical_array(1), logical_coarray[*], non_integer, non_character
13
14  !___ standard-conforming statements ____________________________
15  error stop
16
17  !___ standard-conforming statements with stop-code ______________
18  error stop int_code
19  error stop 5
20  error stop (5)
21  error stop ((5 + 8) * 2)
22  error stop char_code
23  error stop 'c'
24  error stop ('c')
25  error stop ('program failed')
26  error stop int_array(1)
27  error stop char_array(1)
28  error stop int_coarray
29  error stop int_coarray[1]
30  error stop char_coarray
31  error stop char_coarray[1]
32  error stop array_coarray(1)
33  error stop array_coarray(1)[1]
34
35  !___ standard-conforming statements with stop-code and quiet= ___
36  error stop int_code, quiet=bool
37  error stop int_code, quiet=logical_array(1)
38  error stop int_code, quiet=logical_coarray
39  error stop int_code, quiet=logical_coarray[1]
40  error stop int_code, quiet=.true.
41  error stop (int_code), quiet=.false.
42
43  !___ non-standard-conforming statements _________________________
44
45  ! unknown stop-code
46  !ERROR: expected end of statement
47  error stop code=int_code
48
49  ! missing 'quiet='
50  !ERROR: expected end of statement
51  error stop int_code, bool
52
53  ! incorrect spelling for 'quiet='
54  !ERROR: expected end of statement
55  error stop int_code, quiets=bool
56
57  ! missing scalar-logical-expr for quiet=
58  !ERROR: expected end of statement
59  error stop int_code, quiet
60
61  ! superfluous stop-code
62  !ERROR: expected end of statement
63  error stop int_code, char_code
64
65  ! repeated quiet=
66  !ERROR: expected end of statement
67  error stop int_code, quiet=bool, quiet=.true.
68
69  ! superfluous stop-code
70  !ERROR: expected end of statement
71  error stop int_code, char_code, quiet=bool
72
73  ! superfluous integer
74  !ERROR: expected end of statement
75  error stop int_code, quiet=bool, 5
76
77  ! quiet= appears without stop-code
78  !ERROR: expected end of statement
79  error stop quiet=bool
80
81  ! incorrect syntax
82  !ERROR: expected end of statement
83  error stop ()
84
85  ! incorrect syntax
86  !ERROR: expected end of statement
87  error stop (2, quiet=.true.)
88
89end program test_error_stop
90