<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/55086>55086</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Inconsistent check for integer type boundaries in flang
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          chilikink
      </td>
    </tr>
</table>

<pre>
    Compilation of the following code
```
USE, INTRINSIC :: ISO_FORTRAN_ENV
COMPLEX(REAL32), PARAMETER :: C1 = (+2147483647_INT32, -2147483648_INT32)
COMPLEX(REAL32), PARAMETER :: C2 = (+2147483648_INT32, -2147483649_INT32)
INTEGER(INT32), PARAMETER :: I1 = -2147483647_INT32
INTEGER(INT32), PARAMETER :: I2 = -2147483648_INT32
INTEGER(INT32), PARAMETER :: I3 = +2147483647_INT32
INTEGER(INT32), PARAMETER :: I4 = +2147483648_INT32
END
```
with flang on the branch release/14.x (commit 9a3e81e1f91fa8793857fdfdacfd7e70ac365bb8) results in the following errors:
```
$ flang -c test.f90
error: Semantic errors in test.f90
./test.f90:3:37: error: Integer literal is too large for INTEGER(KIND=4)
  COMPLEX(REAL32), PARAMETER :: C2 = (+2147483648_INT32, -2147483649_INT32)
                                      ^^^^^^^^^^^
./test.f90:3:56: error: Integer literal is too large for INTEGER(KIND=4)
  COMPLEX(REAL32), PARAMETER :: C2 = (+2147483648_INT32, -2147483649_INT32)
                                                         ^^^^^^^^^^^
./test.f90:5:36: error: Integer literal is too large for INTEGER(KIND=4)
  INTEGER(INT32), PARAMETER :: I2 = -2147483648_INT32
                                     ^^^^^^^^^^
./test.f90:7:36: error: Integer literal is too large for INTEGER(KIND=4)
  INTEGER(INT32), PARAMETER :: I4 = +2147483648_INT32
                                     ^^^^^^^^^^
```
The errors are not consistent. For complex parameters, the minimum integer of the type `INT32` is `-2147483648`, while for integer parameters the minimum integer of the type `INT32` is `-2147483647`. The maximum value is the same in both cases (2147483647). The integer literal boundaries are tested in the file `flang/test/Semantics/int-literals.f90`, but the test is only performed for the complex-type parameters there.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzdVdFuozgU_RryYgURAwEeeMgkZBVtm47SzmjfKgOXxFuDI9tM27_fayBpm2Y109loR5rIEbHNPeee45vrXJbP6VzWey6Y4bIhsiJmB6SSQshH3mxJIUtwvIXjzZypN4xu-uU2c-icrNZ3m9X6djUnjj_DQVa3N_fLm83dZra-z9Zf-5fnN9efr7K_HBpvstmVTx2a2ODPs83sOrvLNofg-QR_LQi-59BPdBJEQexPg-geWWzQnIyPi_FhMfkgBT1HEZ-jSE4ocJb9kW0w9Lh-jmHVixi_y_9DIPQEJP4ZEH_Q-t7LD8EE72DeZJOtF2dL5JGbHakEwzLC0rJ1lSvWFDuiQADT4NDlJHCf7FkUsq65IQnzIZ7ApEomFYujxI_DqCqrkhVVGUHkscKfhnmOR5cgiG6F0YQ3JyULSkmlbe7nknJoMOQ0LogBbdwqGba6QCv4FmrWGF4MUB3FmzddTP244s98-41s5BFi1RjYgiKCG1BMEK6JkZIIprY2V0VevP9zhf75i-BYZ4T8D8VMfujjhNl3xr_5EU5_Rz8uZlFobbqkRRfpK5cQfE5t9KvUfqdzXUzvSZO5w4Y09A6mgDTS4EXaaK4NNMYlS5SHHW8v4InsmWI1oAfaKrCdrOYNr9sau07v0HAnm-c9EGTo05961jF8vDpJS48YjzsuegsPCC8c_4kgwplLrLaaPXUI35hooTs6XNTIYVtlLrHtF9jftf0jvoqmSR_NT44-l21TMsWhd8vWDZTHvm7FIHHXs4eqwsehRaNrS8QbD1i6K7jeh7w1vS6MsDnKRjyTPSh0pkZ8a5DdHg5i3Ml_65QCd1Smfpn4CRsZbgSkq-blIEmxg-LhjdMdyCs9KKJLfNQqke6M2Xf3El3i2OLt2OYu0uNEiG-Hx3iv5N9QWJFc6xaswjD04ulolwJeiH4R5YzlQZBHJYsiL6YJJGEcAw2mI8FyEDp1wk8OpQ08kg4CfzvhYsRT6lHqBTSkEz_0PDeZ-H6Vx-BHZVDRgDmBh7Zy4do8XKm2I5V2KeXtVuOmQN36ZZNpzbcNQEeH-Kw1O6nSAuuPP_DmYdSRp13y_wB_s9RK">