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

    <tr>
        <th>Summary</th>
        <td>
            Incorrect warning about return statement in the main program
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          chilikink
      </td>
    </tr>
</table>

<pre>
    Compilation of the following code
```
SUBROUTINE S()
RETURN
END SUBROUTINE
```
with flang on the branch release/14.x (commit 9a3e81e1f91fa8793857fdfdacfd7e70ac365bb8) results in an incorrect warning about return statement in the main program (there is actually no main program) in the flag `-std=f2018` is used:
```
$ /opt/llvm-14.0.0/bin/flang -std=f2018 -Wall -c test.f90 
./test.f90:2:1: RETURN should not appear in a main program
  RETURN
  ^^^^^^
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJylUktv5CAM_jXJxZqIkCGPQw7tzlTqpSv1oT07hCRsCYyA7Gz__TqZVn2ot5UA2cb4-_zhzvUv7Q83n7TBqJ0FN0CcFAzOGHfWdgTpepWwQ8KukpK9rs19eLq-__n0eHt3hIeE1wlvLvH74-PT_d3FPt4d4D3v2zJnHScYDBIUwa_YnUcrJ_DKKAwq4Tf5PvsLBCHdPOsIDRaqzlU-NPmAddUUtaiGfuhRDn2lKoayKEXXrYyoSFhMDKAtoKVTOu-VjHBGb9fusHNLpKy4eAshYlSzsnFNX5nMSMbJu9HjvBKgmFegA6CMCxrzAtZ9SlohX99SSyNQl7sQ-6Q4DJzlNbnr6yUoCl19K0fC94R0406RTmP-zDvqnmWMvE5bOi9SfawKu1_EBXYSogoxGxoGl1oZpb-FCI_TzmnD5YcgTG4xPbUQAU8nhX5T6XM_Wx2Aj38KkIjj1_W5lbRvi74pGkyjjka1t_-he7p4004xnsIqGb-hNdLILF1G4_Cq0ZtU9OQ3oZCrQ1hUIEMIVrN0agsUgpeizIuqLusmL0reNYUsOlEjL1mVGuyUCW0irhPOrTrDVoLsRBxS3XLGOdtzwRkT-ybrkAZNVtUgFea8rpI9U8TaZCuPzPkx9e1GqVvGQJdGhxjeLzEEPVqlNjiqj0ucnG_lpI1-1vY53cDbjfw_J9MdRg">