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

    <tr>
        <th>Summary</th>
        <td>
            [flang] Allow constant expressions in DATA statements
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang
      </td>
    </tr>

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

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

<pre>
    In most contexts that allow constants, Fortran allows a constant expression. But in `DATA` statements, based on my reading of the standard, only a constant (either a literal or a named constant) is allowed.

Here's a program that illustrates that:
```
program main
  character*2 :: ary4
 data ary4/"abcdef"(3:4)/
end program main
```
When I compile this with `flang`, I get error messages:
```
error: Could not parse const.f90
./const.f90:3:21: error: expected '/'
    data ary4/"abcdef"(3:4)/
                      ^
./const.f90:3:3: in the context: DATA statement
    data ary4/"abcdef"(3:4)/
 ^
./const.f90:3:3: in the context: declaration construct
    data ary4/"abcdef"(3:4)/
    ^
./const.f90:2:3: in the context: specification part
    character*2 :: ary4
    ^
./const.f90:1:1: in the context: main program
  program main
  ^
```
The only other compilers I could find that don't compile this program are the Intel compilers -- ifort and ifx.  GNU, NAG, nvfortran, and IBM all compile it without error.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVE1zozgQ_TXypSuUEAbbBw5Msp71Yec0W3tuUAPaEhIlNZnk328JnMTZmWxtXKYoqT_e6-Z1Y4xmcES1KL-I8mGHC48-1HNkMq4nq3et18_1xcHkI0PnHdMTR-ARGdBa_yPdRUbHUah7OPvAAd1mioCvVqCnOVCMxrsMviwMxoGo5EPzvRGVhMjINNE1S4uRNHgH0zMEQm3cAL4HHik5Oo1BJzfv7PMthFBHMjxSAARrmAJa8OngcCL96ifUCUzcKJLOhGyEbH6nQEIdEuU5-CHgtNVorF0iB2TaihZF8haVvP5l8-I-oXFCNgDdiAE7piBUoyAFFA1geN4nq0bG7aDOQilsO029UEqoYyGKZi_UKVlkQ07Dv1Lfov41koMLdH6ajSXg0UT4YXhMTe0tuiG5qXu4wEAMFIIPMFGMOFD8uYbVnmje-8VqcJ5hxhBp61nWn5JTJtT57Vw0ia_KU9RrOD3N1DFpEOqwFnhYOwL_v2z45U-Uv31AID1JS0kbV3Wmm6SrN1F9msSn8TR1FgOy8W7rWVi6z8N-WKn6GDnO1JnedBv2jOEF9j9l-CFSfn1-gZRU-CLJNcdPyt9S3grr-0jbmPp1Lq9yDXGVbpJab5zeJk17J9SB30v6BQIDrXQujsnepLm7A9P7wIBOg-mfMoCv3_5Mwv_WfE0v99hvKykdktPlyx9p9F9hDK9z45frlGQ7XRf6VJxwR3V-KIpSHosq341111aVUlWOVB6rttBa7mVV5kTFXhVt2-9MraTa50pW-VFWMs_UXh2P-2NftQdNp6oUe0kTGptZ-zhlPgw7E-NCdZ6fpCx3FluycV3FSm1DrFTayqFOAXftMkSxl9ZEjm8p2LBd9_cWUT5A824v32zemL7q-9GIuyXYemSe17WQFHoeDI9Lm3V-EuqccK6vuzn4v6ljoc4r7yjU-Ur9sVb_BAAA__9shvBh">