• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1! RUN: %S/test_errors.sh %s %t %f18
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.
7
8complex, parameter :: okj1 = 127_1, okz1 = (+127_1, -128_1)
9!ERROR: Integer literal is too large for INTEGER(KIND=1)
10complex, parameter :: badj1 = 128_1
11!ERROR: Integer literal is too large for INTEGER(KIND=1)
12complex, parameter :: badz1 = (+128_1, 0)
13complex, parameter :: okj1a = 128_2
14complex, parameter :: okz1a = (+128_2, 0)
15
16complex, parameter :: okj2 = 32767_2, okz2 = (+32767_2, -32768_2)
17!ERROR: Integer literal is too large for INTEGER(KIND=2)
18complex, parameter :: badj2 = 32768_2
19!ERROR: Integer literal is too large for INTEGER(KIND=2)
20complex, parameter :: badz2 = (+32768_2, 0)
21complex, parameter :: okj2a = 32768_4
22complex, parameter :: okz2a = (+32768_4, 0)
23
24complex, parameter :: okj4 = 2147483647_4, okz4 = (+2147483647_4, -2147483648_4)
25!ERROR: Integer literal is too large for INTEGER(KIND=4)
26complex, parameter :: badj4 = 2147483648_4
27!ERROR: Integer literal is too large for INTEGER(KIND=4)
28complex, parameter :: badz4 = (+2147483648_4, 0)
29complex, parameter :: okj4a = 2147483648_8
30complex, parameter :: okz4a = (+2147483648_8, 0)
31
32complex, parameter :: okj4d = 2147483647, okz4d = (+2147483647, -2147483648)
33!WARNING: Integer literal is too large for default INTEGER(KIND=4); assuming INTEGER(KIND=8)
34complex, parameter :: badj4dext = 2147483648
35!WARNING: Integer literal is too large for default INTEGER(KIND=4); assuming INTEGER(KIND=8)
36complex, parameter :: badz4dext = (+2147483648, 0)
37
38complex, parameter :: okj8 = 9223372036854775807_8, okz8 = (+9223372036854775807_8, -9223372036854775808_8)
39!ERROR: Integer literal is too large for INTEGER(KIND=8)
40complex, parameter :: badj8 = 9223372036854775808_8
41!ERROR: Integer literal is too large for INTEGER(KIND=8)
42complex, parameter :: badz8 = (+9223372036854775808_8, 0)
43complex, parameter :: okj8a = 9223372036854775808_16
44complex, parameter :: okz8a = (+9223372036854775808_16, 0)
45
46complex, parameter :: okj16 = 170141183460469231731687303715884105727_16
47complex, parameter :: okz16 = (+170141183460469231731687303715884105727_16, -170141183460469231731687303715884105728_16)
48!ERROR: Integer literal is too large for INTEGER(KIND=16)
49complex, parameter :: badj16 = 170141183460469231731687303715884105728_16
50!ERROR: Integer literal is too large for INTEGER(KIND=16)
51complex, parameter :: badz16 = (+170141183460469231731687303715884105728_16, 0)
52
53end
54