<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/58927>58927</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang] Allocate with source specifier experiments
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
PeixinQiao
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
PeixinQiao
</td>
</tr>
</table>
<pre>
This is testing for https://reviews.llvm.org/D137812.
```
$ cat run.sh
#!/bin/bash
echo "---------- gfortran ----------"
gfortran $1 $2 && ./a.out
echo && echo "---------- flang-new ----------"
flang-new -flang-experimental-exec $1 $2 && ./a.out
```
### Case 0: scalar
```
program main
real :: a = 5.
call test1(a)
call test2(a)
contains
subroutine test1(a)
real, save, allocatable :: x1, x2, x3, x4
integer :: sss
real :: a
allocate(x1, x2, source = a)
allocate(x3, source = a)
allocate(x4, source = a, stat=sss)
print *, "allocatable: ", x1
print *, "allocatable: ", x2
print *, "allocatable: ", x3
print *, "allocatable: ", x4
print *, sss
end
subroutine test2(a)
real, pointer :: x1, x2, x3, x4
integer :: sss
real :: a
allocate(x1, x2, source = a)
allocate(x3, source = a)
allocate(x4, source = a, stat=sss)
print *, "pointer: ", x1
print *, "pointer: ", x2
print *, "pointer: ", x3
print *, "pointer: ", x4
print *, sss
end
end
```
```
$ bash run.sh case00.f90
---------- gfortran ----------
allocatable: 5.00000000
allocatable: 5.00000000
allocatable: 5.00000000
allocatable: 5.00000000
0
pointer: 5.00000000
pointer: 5.00000000
pointer: 5.00000000
pointer: 5.00000000
0
---------- flang-new ----------
allocatable: 5.
allocatable: 5.
allocatable: 5.
allocatable: 5.
0
pointer: 5.
pointer: 5.
pointer: 5.
pointer: 5.
0
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztFsmOmzD0a-BiBRkDGThwSCeacyv1Bww8wJUDkW1m0r_vM2FLQmYmatVealmGt69esrb4mX6vhSY4DWgjmoqUrSK1MUftBDuHveBU8CrgTXtSvh68VlWI2vvBU-wzz6F7h-6GdUuHeQZZSHJuiOoaT9dkRAYO81FBJhq7cl0vVUBet8RhbDMNUqE_RvGGzDhkOLNPNLTl24XhssVJPFTOvbYzK9p7hhVLpeRNtWngbc3Ugnj-hdMRlDhAY7hEAPKPnbjKz5wQO8kz10AoJp3onEuuVoWOqq0UP5ADx_z1GEIUcElssVCU48-eRN5IQ02yryzmPOYOS24I7IKQtxiPaPTIprtMYQCigVUtZ-MOeyaav4L9otoWq84zCaNPJ98STqxfg34NZwWiMVCBGpm11pfKp8hG9EwebKHdeGlDt53KoU_Epa9L_uDTnOEtJ8KGGwSst0u5o8JwsPw7y4O9s8iGjcF2k3XTf1iCPSwRPCwR3pFYlASa4k5nsLudcWxtidX_bmBDJj7ZCSvc73TBCvc7HbDC_Uj1p5_rI-32BrAn_HgF5HjCUeqVCR3K9sExfzZ71a04Io8Ow0L_km0eQ8hkkdl7Qn-N5ca7m6yvXnnrGZjulD9IWEvaRPxN5HVLupD6222M75aEbt0iDYokSLhrhJGQOtGXPhVOtCe7YbeTN2HqcavrI-SiFHgyzfe-djsl08unUoUyXebl7QEB-14aPhu8uH9AbhAUWneAB8VLFCfsya3TkkYFi8qyBFawIihzSvOM5VDmPCjDLHElz0Bq6yRu1rOfuGmjvStSRhnzcdAgiNnWo6ygEY0j3w8j5kPshBTwqSCnp5ur0t6drKs0EqXQZn7XuVxrUTUAg6mvIE6i-SZ4O9jjnalblc54tw8m7SP5BS9wwVc">