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

    <tr>
        <th>Summary</th>
        <td>
            [flang] Inquiry on the KIND of a kind parameter of derived type failed
        </td>
    </tr>

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

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

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

<pre>
    Consider the following code:
```
type :: dt(k)
  integer(8), kind :: k
end type
type(dt(4))  :: d1
print*, d1%k%kind
end
```

Flang failed to compile the code above with
```
t.f:5:12: error: 'k' is not an object and may not be used as the base of a component reference or type parameter inquiry
  print*, d1%k%kind
             ^
```

All ifort, gfortran and XLF compile and run the code successfully. 
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8UkGPmzwQ_TXDZbQRDHECBw58yRdp1arnXg0ewI1jp7bJKv--spPuVlupFohh5Hkz782TIejZMncg_gNxLOQaF-e7o7SazeGwsC0Gp-7dwdmgFXuMC-PkjHFv2s44OsVQ91D2sCufT9nH-5UxpeseVQRqzkAtlD2itpFn9kBNk1J0wLO26vfdM5Q9W4Wp_gkD1GSEbb7e4jtsBWV_9dpGoD7hqApInNOrrXrgfJoKyv5kpJ1xktqwwuhwdJerNpxJJSooB3djfNNx-UxpM0HdC6j7ilJ_9t75FADtz0B71AGtiygtuuEHjylSeJH3nB0Y18AKZcitBhkY3YQyD-As24ieJ_ZsR0bnswB4lV5eOLJHbX-u2t-zgv_ijH8eEP__LUBvDOrJ-ZjK5xR4afOo37-e3uVI_361H7KEdRw5hGk15r7BQnW1autWFtxVe9HW6bTF0tG0qyWpvWx4rIZGiKakVrXDbqukkE1d6I5KElVZVpXYUtVuxlY1kniQ064Wza6BbckXqc3GmNtl4_xc6BBW7qpdJeqmMHJgE7JXiaa0TKj7yTsb07qJkoN9l2pfhnUOsC2NDjF8oEUdTfb6o1gc8fWhLboH3S-v346P1WRjfuzATajY6xs_7Pk0UbF60y0xXkPyJZ2ATrOOyzpsRncBOqXGz8_L1btkDKBT5hSATk9at45-BQAA__-26xW1">