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

    <tr>
        <th>Summary</th>
        <td>
            [fang] Compilation error in static statement
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    [As discussed at Discourse](https://discourse.llvm.org/t/request-advice-on-reporting-many-errors-found-in-fortran-test-sets/65868), we Fujitsu have started to report bugs.

```
Version of flang-new : 16.0.0(e0fb01e97b6b7d2fe66b17b36eeb98aa78c6e3bb)
```

It seems that `static` statement cannot be used in a program.  
GNU's Fortran compiler is OK.  

The following are the test program, flang-new compilation results, and gfortran compilation results.  

memcpy007_.f90:
```fortran
program main
integer j
 j=0
 call sub(j)
end program main

subroutine sub(j)
integer j
data k/0/
integer*4 x(10),y(10)
static x
  do i=1,10
   x(i) = i
  enddo
 write(6,*) "x(after)=",x
end subroutine
```

```
$ flang-new -flang-experimental-exec memcpy007_.f90
error: Could not parse memcpy007_.f90
./memcpy007_.f90:11:8: error: expected '('
  static x
         ^
./memcpy007_.f90:11:1: in the context: statement function definition
  static x
  ^
./memcpy007_.f90:11:1: in the context: declaration construct
  static x
  ^
./memcpy007_.f90:8:1: in the context: specification part
  integer j
  ^
./memcpy007_.f90:7:1: in the context: SUBROUTINE subprogram
  subroutine sub(j)
  ^
$
```

```
$ gfortran memcpy007_.f90 -fdec-static
$ ./a.out
 x(after)=           1           2           3           4           5           6           7           8           9          10
$
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJydVm2PmzgQ_jXkywhkILx94MN2062qk1rprntfTwYPiXOAU9vsy7-_MRBCst1W1wjM2B7P88x4xk6lxGvpJR_uDAhp6sEYFMAt7KijBm3QS3ZelB-sPRkvvvOiB3rEeTJo26c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