Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Semantics / error_stop1a.f90
blobf145ccbbe2e7a09a0ef65a062ccf77e42dc86e93
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
6 implicit none
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 ____________________________
15 error stop
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]
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 _________________________
45 ! unknown stop-code
46 !ERROR: expected end of statement
47 error stop code=int_code
49 ! missing 'quiet='
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
65 ! repeated quiet=
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
73 ! superfluous integer
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
79 error stop quiet=bool
81 ! incorrect syntax
82 !ERROR: expected end of statement
83 error stop ()
85 ! incorrect syntax
86 !ERROR: expected end of statement
87 error stop (2, quiet=.true.)
89 end program test_error_stop