[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Semantics / int-literals.f90
blob6d4a63e4bba7155119f0d795c31c5f40fac894e3
1 ! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
2 ! Fortran syntax considers signed int literals in complex literals
3 ! to be a distinct production, not an application of unary +/- to
4 ! an unsigned int literal, so they're used here to test overflow
5 ! on signed int literal constants. The literals are tested here
6 ! as part of expressions that name resolution must analyze.
8 complex, parameter :: okj1 = 127_1, okz1 = (+127_1, -128_1)
9 !ERROR: Integer literal is too large for INTEGER(KIND=1)
10 complex, parameter :: badj1 = 128_1
11 !ERROR: Integer literal is too large for INTEGER(KIND=1)
12 complex, parameter :: badz1 = (+128_1, 0)
13 complex, parameter :: okj1a = 128_2
14 complex, parameter :: okz1a = (+128_2, 0)
16 complex, parameter :: okj2 = 32767_2, okz2 = (+32767_2, -32768_2)
17 !ERROR: Integer literal is too large for INTEGER(KIND=2)
18 complex, parameter :: badj2 = 32768_2
19 !ERROR: Integer literal is too large for INTEGER(KIND=2)
20 complex, parameter :: badz2 = (+32768_2, 0)
21 complex, parameter :: okj2a = 32768_4
22 complex, parameter :: okz2a = (+32768_4, 0)
24 complex, parameter :: okj4 = 2147483647_4, okz4 = (+2147483647_4, -2147483648_4)
25 !ERROR: Integer literal is too large for INTEGER(KIND=4)
26 complex, parameter :: badj4 = 2147483648_4
27 !ERROR: Integer literal is too large for INTEGER(KIND=4)
28 complex, parameter :: badz4 = (+2147483648_4, 0)
29 complex, parameter :: okj4a = 2147483648_8
30 complex, parameter :: okz4a = (+2147483648_8, 0)
32 complex, parameter :: okj4d = 2147483647, okz4d = (+2147483647, -2147483648)
33 !WARNING: Integer literal is too large for default INTEGER(KIND=4); assuming INTEGER(KIND=8)
34 complex, parameter :: badj4dext = 2147483648
35 !WARNING: Integer literal is too large for default INTEGER(KIND=4); assuming INTEGER(KIND=8)
36 complex, parameter :: badz4dext = (+2147483648, 0)
38 complex, parameter :: okj8 = 9223372036854775807_8, okz8 = (+9223372036854775807_8, -9223372036854775808_8)
39 !ERROR: Integer literal is too large for INTEGER(KIND=8)
40 complex, parameter :: badj8 = 9223372036854775808_8
41 !ERROR: Integer literal is too large for INTEGER(KIND=8)
42 complex, parameter :: badz8 = (+9223372036854775808_8, 0)
43 complex, parameter :: okj8a = 9223372036854775808_16
44 complex, parameter :: okz8a = (+9223372036854775808_16, 0)
46 complex, parameter :: okj16 = 170141183460469231731687303715884105727_16
47 complex, parameter :: okz16 = (+170141183460469231731687303715884105727_16, -170141183460469231731687303715884105728_16)
48 !ERROR: Integer literal is too large for INTEGER(KIND=16)
49 complex, parameter :: badj16 = 170141183460469231731687303715884105728_16
50 !ERROR: Integer literal is too large for INTEGER(KIND=16)
51 complex, parameter :: badz16 = (+170141183460469231731687303715884105728_16, 0)
53 end