<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJzdV8ty4yoQ_Rp5Q0klIT8XWuQm1z9ws59CgGymEKgAje18_TTIsmSNH0nN1CxuypFtaJrTp083uNTsVLxz6zhDbi8sOgi3R5UkaoeyLMmSNMKvKMNJmmSIKIayHD6mSZS-RelL93zVygrGDTjgqNJS6oOA5e6gEdWM2yh_GZtHy7ROqk0K78PMMu1elTbOENWN1pq1kqO6-4aQqBspqHBIacXHLqlWjghlx2MI2bY0unVCcaQbbojjEV5_-Hgaoym3NsKb6xUIGU6ktxDKceXAXihwAYbIY81f0Md0BSktIKYuLDEVoXyYu8JQn77BN3BJLvui89-NwPqpp4DI2J5DhoYthxk_fgNf4IG1xhPTw7s47kmaxEuJlAOBns9RMAcjAssRfgHQ4Qn-8OodlGG4bSXQFPSAVz6oCZm303hFooUorsO6OdmbTAx6GYxsvMW1zi5aHJuB9CcaVl_SsHqg4afqZUb84GYIu7WjorirHq-cPpfHYfgIY28omyR0KJDjuEDyNydq6A4HPUrzhNQxuhvgBwfr05VWHsB-KPjTYHsKsWBQ2Gh4Au-y_-2kqwdJf9V1I6TvZaErSvmjRjuuAlMWcWO0AbgNpHvocaD0EyLGixHiO4GmvQ_ort7Fr1qxey5lN9Y13Ziirjtej6lh7CZUjy0-N-xfNjkH7fF6AqH4-mJfobq1DpUcevuNToYgQDJ0iY4GsOTHc-omPSXCW91ArraBJUHhkwcGb_1Zsi2FgmeVrT0Sy2uinKAdlxbcfTLQcB7dCzSBDYDDbJ1AjsFoCf-Zt0Z_gYI7TbXT7lVLRaO_aPHv9PWM0I6CCaH_PSQ0qMmbwTCs2esaMG6VoA0cSVtXN77uwBOqyEWyECgEaR1xrUVpx93nMaG4K7PYtlUljqjPCoqBNgM9T9DeggnDqdPm9JkNhKKyZR79Fysk3F4eCadzA4Lxj8V90cBVSWk3lsY4q1_uqXdE8Mdf_7cCuQD-E8r3RrHih7v6z57ov1PXRf8Xf3FFs_ulUDFetru4VQ0xcLLHldIxUUSePjiLdfkdysLGcKkYLJ6r_d3f5c9nj0WVPwhDNDVcwUQD556Gy7rpLYAvf7cnYEmMfztw5G9x8_R7zRfYH74UUurgrPLCBzYUI4aF5VIA78mMFTnb5BsyI63ba1N8cANbiFlrZLF3rulufVtPG-BoywTWDsyF4oTk-1h9eVvbwu8GvF3kc5zO9kWGyYotCc7ykmfZuqTzap6vKNtQRikrVzNJSi5tES3-iTD2lAcX8DlavM1-H4EocIpxmuFlluL1fJ1gUrFNyqtFuqwWfD0HqkCAQibeT6LNbmaK4BIya2FSCuvsMEmsFTvFeQAMCJ1wkhddL4MVXqZDRRGza2u4C51_nEkN3WWoKjsLWIsA9CetnBmP>53420</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            flang bug in procedure arguments with local interfaces
        </td>
    </tr>

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

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

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

<pre>
    Tested this with flang 11.1.0, 12.0.1 and 13.0.0.

Consider the following two codes:

`m.f90`:
```fortran
module m
  implicit none

contains

  subroutine operate(z, process)

    real, intent(inout) :: z

    abstract interface
      subroutine my_sub(a)
        implicit none
        real, intent(inout) :: a
      end subroutine
    end interface
    procedure(my_sub) :: process

    call process(z)
    write(*,*) 'The result is:', z

  contains

    subroutine sint
    end subroutine sint

  end subroutine operate

end module m
```

and

`n.f90`:
```fortran
module n
  implicit none
contains

  subroutine driver
    use m
    implicit none
    real :: x
    x = 1
    call operate(x, process=timestwo)
  end subroutine driver

  subroutine timestwo(y)
    implicit none
    real, intent(inout) :: y
    y = 2 * y
  end subroutine timestwo

end module n
```

Compiling with llvm generates error reports:
They are simply compiled with:
```shell
flang -c m.f90
flang -c n.f90
```

llvm-11.1.0:
```
error: 'my_sub' must be an abstract interface or a procedure with an explicit interface
/opt/generic/llvm/11.1.0/bin/f18: semantic errors in n.f90
```

llvm-12.0.1:
```
./m.f18.mod:6:11: error: 'my_sub' must be an abstract interface or a procedure with an explicit interface
  procedure(my_sub)::process
            ^^^^^^
/opt/generic/llvm/12.0.1/bin/f18: Semantic errors in n.f90
flang: in /home/nicpa/tmp, f18 failed with exit status 0: /opt/generic/llvm/12.0.1/bin/f18 -module-suffix .f18.mod -intrinsic-module-directory /opt/generic/llvm/12.0.1/include/flang -c n.f90
```

llvm-13.0.0:
```
./n.f90:10:5: error: 'my_sub' is not a procedure
      call operate(x, process=timestwo)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
./m.f18.mod:6:11: error: 'my_sub' must be an abstract interface or a procedure with an explicit interface
  procedure(my_sub)::process
            ^^^^^^
error: Semantic errors in n.f90
flang: in /home/nicpa/tmp, flang-new failed with exit status 1: /opt/generic/llvm/13.0.0/bin/flang-new -fc1 -module-suffix .f18.mod -fdebug-unparse -fno-analyzed-objects-for-unparse -c n.f90
```

This compiles fine with multiple other compilers and as far as we (@jme52) can tell is standard compliant.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzdV12TqjgQ_TX4koKCKA4-8DA7s_6BnfetQBLNrZBQSbjq_PrtBBHk-jFTdes-rKWgSdM5ffp0J1aansoPZh2jyO2FRQfh9ohLonYoy5IsSSP8hjKcpEmGiKIoW8LXNInS9yh97a9vWllBmQEHDHEtpT4IeNwdNKo1ZTZavk7No3XaJHyTwn2cWaf9m2vjDFH9aKNpJxlq-l8IiaaVohYOKa3Y1GWtlSNC2ekYQrarjO6cUAzplhniWISLTx9Pa3TNrI3w5voJhAwj0lsI5ZhyYC8UuABD5LEuX9Hn_AlSWUBcu_CI4aRm49wVhub0L_wCl-SyLjq_bgQ2TD0FRKb2DDI0LjnO-PEb-AIPtDOemAHexfFA0izemkg5Euj5nARzMCKwHOFXAB2u4A-_fIAyDLOdBJqCHvCLD2pG5u00XpFoIYrrsG5ODiYzg0E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