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

    <tr>
        <th>Summary</th>
        <td>
            [Flang] Incorrect diagnose on SELECT TYPE selector
        </td>
    </tr>

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

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

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

<pre>
    Consider the following code:
```
module m
type base
integer i
end type
end module

subroutine sub(arg)
use m
class(base) :: arg(*)
select type (arg)
  type is (Base)
     print *, "typeis"
  class default
     print *, "classdefault"
  end select
end
```

Flang currently issues an error as:
```
error: Semantic errors in t.f
./t.f:10:14: error: Whole assumed-size array 'arg' may not appear here without subscripts
  select type (arg)
               ^^^
./t.f:9:16: Declaration of 'arg'
 class(base) :: arg(*)
                 ^^^

```

It doesn't seem correct to me. The SELECT TYPE inquires the dynamic type of the `selctor`. It shouldn't matter if it is a assumed-size whole array or not.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVE2L8zYQ_jXyZVjjyHYSH3zIm2xgoYfCu1B6lK2xrSJLqUbqkv76IinJsqFdaozEaD6e0TwzEkRqNog9a3-w9lSI4Bfr-pMwCvXxuKApBiuv_dEaUhId-AVhslrbD2VmGK1EVh9YdWLVgW2r25_E1cqgEdYs-esFYRCEWVTG44wOVBbRSIgWn1L2vgVOK4XB2eCVQaAwML4Xbma8y8pAD6RRCyLG9wmMdxDzqw-QrPeMHx4-hBpHn3DhKRzkU0VR8SMHumsA4OKU8ZBiHYFxHo0VMc7vNikHkDiJoP03jsnubvbpHguQs3sU5F9LnNezFpGK4Bwar6-giAISCAPonHUg6L8oSvpYnJ-4CuPVmD0IlAFfTtmoZPwchfqwqeLSRIeH52-L1QiCKKwoX0j9jSCcE1dgfJcquoNVXMFYD-JyQeFgQYfwofxig49M0ujUxdP97t-y8uVj7evtf8qzi2luY3YnHLVwwitrwE6fOd3i_e9WgefvCfsbdt48SItkGN95IMQVRutcuqKFFUt4XxB-vv7yenyH999_fQVl_gzKIaVRk1cjVjXmctgpnbFtRahHbx3bViW8eaDFBi0zxCq8j4M1gfKxgcVXcj4yX4ki6yIvZSH7WnZ1JwrsN7tqX_Et502x9Chw27ZSVHI_dEMlm27qeNNI3u3EruWyUD2veFPxTbvpmrppyjruopUt7mvcScmaClehdKn1X2tp3Vyk5uz3m25TFVoMqCk9PZxPsYtZfZicNT42POeMHx-Kr1J9oFvHpqlrT4XrI8TLEGZiTaUVefoE9crr9MSlUWHtCd7MnQWpxGwsIVjzhYbch9YVwel-8f6SpoifGT_Pyi9hKEe7Mn6OILft5eLsH3Fo-TnPIOPndNN_AgAA__-8vptU">