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

    <tr>
        <th>Summary</th>
        <td>
            Allocate character with source returns stat = 0 when already allocated
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang:ir,
            flang:runtime,
            flang
      </td>
    </tr>

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

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

<pre>
    The issue domes from the fact that `AllocatableInitCharacter` is called before `AllocatableAllocateSource` and reset the descriptor before the check is done. 

```fortran
program test
character(:), allocatable :: ch
ch = 'dummy'

allocate(ch, stat=istat, source='fail?')
if (istat == 0) then
  print*, 'fail to report correct stat'
end if
end program
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxcUlFvszgQ_DXLy6qRWSiEBx5yjSLd890fMPYSfGdwZC-t-u8_GUhbVULYHnlndryjU3L3hbmH17_g9VroVaYQe-N55kXetS-GYD_7fydGl9LKaMPMCccYZpSJcdRGUCYtCI26eB-MFj14_ntx8jbpqI1whEahS2i092xx4DFE_nX_2PI_YY2Gc4FeLEZOLJuO5WSie0iIz_qMmonN_5nahoVPCOoK6nL8G7V_Y4gS9bKjjxjuUc8onGRHzFeTdIbqAtQBvaH-7gwzWl3QTM8ChOqKQK1d5_kTqP0pexQy0NlMmSmJFqiublvzeTdYXYHaUTsP1S1TULfXuxGBztvtLJOVFFCX3R4WEB_RLQJ0yXQHC0rAyI8QBU2IkY3sws_meLHoxu_98Q6_nmo_FravbFd1uuC-bNqma5tatcXUlwN3rzWdm5JNxQ3XXWPOVJVDozvVVmXhelJUKaKyVHVTtyfu2rpWjW7KqqutHaBWPGvnT96_z6cQ78UWqr5R564tvB7Ypy2JRKPXyx2qi4tABPT2A4rrIm7mXzhRzm_sM_XLsN4T1Mq7JOlbTJx47p9Rw6_R44eT6ZgMRpY1LgmfI0CFHxMvqH1kbT-f0WBbrNH3k8gjbbm5Ad3uTqZ1OJkwA92y7LG8PGL4j40A3TbDCei2ef4TAAD__zqwFyU">