<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/89506>89506</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-repl can not correctly execute top-level for-loop statements
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
wlonestar
</td>
</tr>
</table>
<pre>
Consider the following piece of code:
```cpp
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
std::cout << i << ":" << j << "\n";
}
}
```
When running this code in `clang-repl` I found it will set `i`, `j` as global variables, so the output will be:
```
0:0
0:1
0:2
```
I have to put the double loops into a function and execute the function, but this contradicts the original intention of the usage of interpreter.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsU8uO4yAQ_Bp8aSUiOLbjgw95KNJ8wZ4xbttEBCxokp2_X4GTzRxGQkpBdRVNpS1D0JNF7Fh1YtWlkJFm57uncRYDSV_0bvjuzs4GPaAHmhFGZ4x7ajvBolEhuBGUG5CVR8YvjB9ZzdellmU9GZ0HJg7aEmhg5QU4K08ZnqHMkIlTXi2w5rSKAH7Ibh_Z7SO7_SoDCDSkbsqjcpFSeVLoN2BCJFaI98HtJ1OdbS5427Hm8nrWf_B-37r9M6MFH61NidCsQ04DtIUUgZF22nhcDKs5fMHooh1AEzy1MRCQUpFOXuKc4C2VyQCTcb008JBey95gSHRwOX4XaYkvg_6X1NctZ-XxB9x9oPi1_gtm-UAgB8k83TO42BsE49wSQFtyIGGMVpF2FqQdAP-iioTrTLyI1GefDXIOlrwctKKwdu71pK00yQ1t9nFjZmKQUx6kxPjFI6HfFkNXDm3ZygK7XbMra1FXh7aYu6ba7ZtGqLbGsen5sC9lq3pVylEchnHYFboTXOz5XvBdJUrebrHCseobifuRi7pu2Z7jXWqzNeZx3zo_FTqEiN2hrXhdGNmjCfmLEMLiEzKZh-NS-C5pNn2cAttzowOFjwtpMth9_nRQ0oJ1BMp5j4rM9yc1t2wMPtCkMd-klCGQJLyjpVBEb7qZaAl5Uq9MXCdNc-y3yt2ZuKYLXz-bxbsbKmLimtsMTFzzM_4FAAD__73dJ2g">