https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122508
Bug ID: 122508
Summary: [OpenMP] Labels referenced in metadirective body and
defined in outer region mishandled
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: parras at gcc dot gnu.org
Target Milestone: ---
Consider the following Fortran code:
```
implicit none
integer :: cnt
1345 format("The count is ", g0)
cnt = 0
write(*,1345) cnt
!$omp begin metadirective when(user={condition(cnt > 0)} : parallel)
write(*,1345) cnt
!$omp end metadirective
end
```
Label 1345 is referenced in the metadirective body and defined in the outer
region. This results in the following errors:
```
$ gfortran -c -fopenmp pr122369-4.f90
pr122369-4.f90:9:19:
9 | write(*,1345) cnt
| 1
Error: FORMAT label 1345 at (1) not defined
pr122369-4.f90:9:19:
9 | write(*,1345) cnt
| 1
Error: FORMAT label 1345 at (1) not defined
pr122369-4.f90:9:19:
9 | write(*,1345) cnt
| 1
Error: FORMAT label 1345 at (1) not defined
pr122369-4.f90:9:19:
9 | write(*,1345) cnt
| 1
Error: FORMAT label 1345 at (1) not defined
```
This is related to PR122369.