xref: /llvm-project/flang/test/Semantics/unsigned-errors.f90 (revision fc97d2e68b03bc2979395e84b645e5b3ba35aecd)
1! RUN: %python %S/test_errors.py %s %flang_fc1 -funsigned
2
3implicit unsigned(u)
4real a(10)
5
6!ERROR: Must have INTEGER type, but is UNSIGNED(4)
7real(kind=4u) x
8
9!ERROR: Both operands must be UNSIGNED
10print *, 0 + 1u
11!ERROR: Both operands must be UNSIGNED
12print *, 0u + 1
13!ERROR: Both operands must be UNSIGNED
14print *, 0. + 1u
15!ERROR: Both operands must be UNSIGNED
16print *, 0u + 1.
17
18print *, -0u ! ok
19print *, 0u + 1u ! ok
20print *, 0u - 1u ! ok
21print *, 0u * 1u ! ok
22print *, 0u / 1u ! ok
23!ERROR: Operands must not be UNSIGNED
24print *, 0u ** 1u
25
26print *, uint((0.,0.)) ! ok
27print *, uint(z'123') ! ok
28!ERROR: Actual argument for 'a=' has bad type 'CHARACTER(KIND=1,LEN=1_8)'
29print *, uint("a")
30!ERROR: Actual argument for 'a=' has bad type 'LOGICAL(4)'
31print *, uint(.true.)
32!ERROR: Actual argument for 'l=' has bad type 'UNSIGNED(4)'
33print *, logical(0u)
34!ERROR: Actual argument for 'i=' has bad type 'UNSIGNED(4)'
35print *, char(0u)
36
37!ERROR: DO controls should be INTEGER
38!ERROR: DO controls should be INTEGER
39!ERROR: DO controls should be INTEGER
40do u = 0u, 1u
41end do
42!ERROR: DO controls should be INTEGER
43do u = 0, 1
44end do
45!ERROR: DO controls should be INTEGER
46!ERROR: DO controls should be INTEGER
47do j = 0u, 1u
48end do
49
50select case (u) ! ok
51case(0u) ! ok
52!ERROR: CASE value has type 'INTEGER(4)' which is not compatible with the SELECT CASE expression's type 'UNSIGNED(4)'
53case(1)
54end select
55
56select case (j)
57!ERROR: CASE value has type 'UNSIGNED(4)' which is not compatible with the SELECT CASE expression's type 'INTEGER(4)'
58case(0u)
59end select
60
61u = z'1' ! ok
62!ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types UNSIGNED(4) and INTEGER(4)
63u = 1
64!ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types INTEGER(4) and UNSIGNED(4)
65j = 1u
66
67!ERROR: Must have INTEGER type, but is UNSIGNED(4)
68write(6u,*) 'hi'
69
70!ERROR: ARITHMETIC IF expression must not be an UNSIGNED expression
71if (1u) 1,1,1
721 continue
73
74!ERROR: Must have INTEGER type, but is UNSIGNED(4)
75print *, a(u)
76
77end
78