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

    <tr>
        <th>Summary</th>
        <td>
            [Flang] Compile error when scalar-int-constant-expr expression specified for KIND= of intrinsic-type-spec in data-component-def-stmt of derived type
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          ohno-fj
      </td>
    </tr>
</table>

<pre>
    ```
Version of flang : 21.0.0(8c7c791284877e36f73c41ffa56b52c13e613993)/AArch64
```

In `data-component-def-stmt` of `derived type`, `scalar-int-constant-expr expression (k3/k1)` specified for `KIND=` of `intrinsic-type-spec` results in a compilation error.

According to the `Fortran Standard 2023: 7.5.4.1 Component definition statement`, only `scalar-int-constant-expr` can be specified in `KIND=`, so there should be no problem with the attached program.


The following are the test program, Flang, Gfortran and ifx compilation/execution result.

FT_PDT_utf32_04_2.f90:
```fortran
program main
  type ty(k1,k2,k3)
     Integer,kind  :: k1,k2,k3
 character(kind= k2**1,len = k1+k2+k3) :: ch0(k2*k1,k3)!ok
 character(kind= k1*k1,len = k1+k2+k3) :: ch1(k2*k1,k3)!ok
 character(kind= k3/k1,len = k1+k2+k3) :: ch2(k2*k1,k3)!ok
  end type ty
 type(ty(2,4,8)):: obj
  print*,'PASS'
end program main
```

```
$ flang FT_PDT_utf32_04_2.f90
error: Semantic errors in FT_PDT_utf32_04_2.f90
./FT_PDT_utf32_04_2.f90:6:22: error: Must be a constant value
       character(kind= k3/k1,len = k1+k2+k3) :: ch2(k2*k1,k3)!ok
                       ^^^^^
$
```

```
$ gfortran FT_PDT_utf32_04_2.f90; ./a.out
 PASS
$
```

```
$ ifx FT_PDT_utf32_04_2.f90; ./a.out
 PASS
$
```


</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0VU1v5DYM_TWai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