<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/96314>96314</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang][debug] Scope of the contained subroutine is not correct.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
abidh
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
abidh
</td>
</tr>
</table>
<pre>
If the following program is compiled with flang, the scope of `sub1` is not the parent function that contains it. As a result, when control is stopped in `sub1`, debugger fails to evaluate the variable in parent function (e.g.`i`) .
with gfortran
```
Breakpoint 1, test::sub1 (m=2) at ../../test1.f90:11
11 print *, "sub1: ", m
(gdb) p i
$1 = 2
```
With flang
```
Breakpoint 1, sub1 (m=2) at ../test1.f90:11
11 print *, "sub1: ", m
(gdb) p i
No symbol "i" in current context.
```
```
program test
integer i
i = 2
call sub1(i)
i = i + 1
call sub2(5)
print *, i
contains
subroutine sub1(m)
integer m
print *, "sub1: ", m
end subroutine sub1
end program test
subroutine sub2(n)
integer n
print *, "sub2: ", n
end subroutine sub2
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VE2P4zYM_TX0hVjDoj82PviQaRCgl1566Fm2aVutLBmSPNP994UUZzOZnRZ76WCgJBT5-B4pPOm9mg1zB_ULEMlejQsQQX3J5B4W67oUyno7fut-nTAsjJPV2r4pM-Pm7OzkisrjYNdNaR7xTYUFJy3NDPRLyveD3RjthNAUfu8FNEWsMDak6006NgGn3QxBWYNhkQEHa4JUxqMKOZ49SnTsdx0i5tvCJiU4qyOQD3bbeERl3nWIiSP3-zyzw0kq7TFY5Fepdxk4NX6VTslecyz8SALoxPmcQ1OoBNZiDsUFivPtTCLnybrgpDkumuL4Tz9fHMu_NqtMQJEGwT5AeYbyHAlG_BXKC0VkGTDPga7piHkin9oCyrMQNywh8Pvf5iIk0DmCAlGSW57j1xhZDzJ0msc-gm-o7qFKIJQXpE_5_vFY28_I-VcR_xv_3yz6b2tvdUxVQBTXNuwu7S2-Bv475J9y_zR4f7ppLymCygSOr-VoiKjezwtxkFon4UAnBdQ-pykEekHxMZmATvUj-Un-0ej-1u-lfu-d3YMyfO-2vuuG33muj9DPTRWRzfgDfLqKFz-O5HY-F0RB5lM-5j_50Ds-5tH0I_jzrrKxK8e2bGXGnfgqTu1JUFVlS9cWZTM1UtRF005N0TZDLybmdjgJMY0TZaqjgqqiISGq6itVOdXNyNxTW8mibPoWqoJXqXSu9euaWzdnyvudu7YpRZVp2bP2hysebpZc0XUx_0u_zx6qQisf_AMhqKCTld4q6gvUL8mEoL7g73cbjN5z7JyfBnCY4mCd4yHk2e50t4Sw-WgcdAW6ziose58PdgW6xrbHx5fN2T95CEDXpMIDXW9CXjv6JwAA___szLQU">