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

    <tr>
        <th>Summary</th>
        <td>
            [Flang] Compilation error when the variable sin is used as sin intrinsic function in block construct
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          ohno-fj
      </td>
    </tr>
</table>

<pre>
    ```
Version of flang-new : 20.0.0(74b56c7eb807e2ba54bd7a2bcfda5d0bceff1c0c)/AArch64
```

When `the variable sin` is used as `sin intrinsic function` in `block` construct, a compilation error occurs.  
The above program is `13-P-21_block_intrinsic2_2.f90`  

If the definition of sin in the following `block` construct:
```
    intrinsic sin
```

is changed to the following, compilation ends normally.
```
 real,intrinsic:: sin
```
The above program is `13-P-21_block_intrinsic2_3.f90`

The following are the test program, Flang-new, Gfortran and ifx compilation/execution result.

13-P-21_block_intrinsic2_2.f90:
```fortran
program main
  implicit none
  real  sin
  sin = 1
  block
 intrinsic sin
    real :: rr = 0
    rr = sin(rr) + 3
    if (rr .ne. 3 ) print *, "NG1", rr
  end block
  sin = sin + 1
  if (sin .ne. 2 ) print *, "NG2", sin
  print *, "PASS"
end program main
```

```
$ flang-new 13-P-21_block_intrinsic2_2.f90
error: Semantic errors in 13-P-21_block_intrinsic2_2.f90
./13-P-21_block_intrinsic2_2.f90:4:3: error: Assignment to procedure 'sin' is not allowed
    sin = 1
 ^^^
./13-P-21_block_intrinsic2_2.f90:11:3: error: Assignment to procedure 'sin' is not allowed
    sin = sin + 1
 ^^^
./13-P-21_block_intrinsic2_2.f90:11:9: error: Function call must have argument list
    sin = sin + 1
 ^^^
./13-P-21_block_intrinsic2_2.f90:12:7: error: Function call must have argument list
    if (sin .ne. 2 ) print *, "NG2", sin
 ^^^
./13-P-21_block_intrinsic2_2.f90:12:36: error: Output item must not be a procedure
    if (sin .ne. 2 ) print *, "NG2", sin
 ^^^
$
```

```
$ gfortran 13-P-21_block_intrinsic2_2.f90; ./a.out
 PASS
$
```

```
$ ifx 13-P-21_block_intrinsic2_2.f90; ./a.out
 PASS
$
```

13-P-21_block_intrinsic2_3.f90:
```fortran
program main
  implicit none
  real  sin
  sin = 1
  block
! intrinsic sin
    real,intrinsic:: sin
    real :: rr = 0
    rr = sin(rr) + 3
    if (rr .ne. 3 ) print *, "NG1", rr
  end block
 sin = sin + 1
  if (sin .ne. 2 ) print *, "NG2", sin
  print *, "PASS"
end program main
```

```
$ flang-new 13-P-21_block_intrinsic2_3.f90; ./a.out
 PASS
$
```

```
$ gfortran 13-P-21_block_intrinsic2_3.f90; ./a.out
 PASS
$
```

```
$ ifx 13-P-21_block_intrinsic2_3.f90; ./a.out
 PASS
$
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcV09v47YT_TT0ZWCBGkpWfNBBSX5e_C7tAlm0x4CiKItbiTRIKtn99gUpO_4TJ95ma7QoYNgmRfK9eTPD0XDn1FpLWZL8luT3Mz76ztjSdNrM26-z2jTfS7Kg2w-9J7T6TVqnjAbTQttzvZ5r-QyEVYA0oQkleFNkdb4QhaxvaCGx5nlWNwXHWrQNzxtaC9m2qaCC4JLgqqqs6BbZdPgJ1vT9eyc1kAX1nYQnbhWvewlOabKgoByMTjbAXVjhlAalvVXaKQHtqIVXZloXT6h7I_4IQ2G083YUnuAdcBBm2Kieh8UgrTUWjBCjdQnAROFLJ4HX5knCxpq15UMAJguasvnnOaaP8eDHF2h8xKRdBjt2B0zf_28hGNHIVmnltypOpOOD1vS9eVZ6_QZZVp2VCQAOzA7KvC2mciA6rteyAW-OQYMWR0roxoE2duB9_z05j2wl7wnevaAHiqx6k8Nf1pFtdTw04cuRUtzKaIaXzu9ODZasdsEZBp9aY73lGrhuQLXfDu0kuJLfpBijzVa6sffJIdwFH7_yyRZqmt2ZOfCdIgBq2PRKKA_aaLmbDEL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