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.
5 program test_error_stop
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
14 !___ standard-conforming statements ____________________________
17 !___ standard-conforming statements with stop-code ______________
21 error
stop ((5 + 8) * 2)
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]
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
.
43 !___ non-standard-conforming statements _________________________
46 !ERROR: expected end of statement
47 error
stop code
=int_code
50 !ERROR: expected end of statement
51 error
stop int_code
, bool
53 ! incorrect spelling for 'quiet='
54 !ERROR: expected end of statement
55 error
stop int_code
, quiets
=bool
57 ! missing scalar-logical-expr for quiet=
58 !ERROR: expected end of statement
59 error
stop int_code
, quiet
61 ! superfluous stop-code
62 !ERROR: expected end of statement
63 error
stop int_code
, char_code
66 !ERROR: expected end of statement
67 error
stop int_code
, quiet
=bool
, quiet
=.true
.
69 ! superfluous stop-code
70 !ERROR: expected end of statement
71 error
stop int_code
, char_code
, quiet
=bool
74 !ERROR: expected end of statement
75 error
stop int_code
, quiet
=bool
, 5
77 ! quiet= appears without stop-code
78 !ERROR: expected end of statement
82 !ERROR: expected end of statement
86 !ERROR: expected end of statement
87 error
stop (2, quiet
=.true
.)
89 end program test_error_stop