Bug 107067 - [OpenMP] ICE with metadirective block statements
Summary: [OpenMP] ICE with metadirective block statements
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 13.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: openmp
Depends on:
Blocks:
 
Reported: 2022-09-28 12:53 UTC by Paul-Antoine Arras
Modified: 2022-09-28 12:53 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Test case triggering an ICE (211 bytes, text/plain)
2022-09-28 12:53 UTC, Paul-Antoine Arras
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul-Antoine Arras 2022-09-28 12:53:09 UTC
Created attachment 53636 [details]
Test case triggering an ICE

The current OG12 implementation handles OMP metadirectives, but it fails to parse the following code:

```
   !$OMP begin metadirective &
   !$OMP   when ( user = { condition ( UseDevice ) } &
   !$OMP     : nothing ) &
   !$OMP   default ( parallel )
   block
      call foo()
   end block
   call bar()
   !$omp end metadirective
```

The `call bar()` statement cannot be parsed properly as the parser expects the `end block` to be immediately followed by `!$omp end metadirective`:

```
f951: internal compiler error: in parse_omp_metadirective_body, at fortran/parse.cc:5895
0x6d6d6f parse_omp_metadirective_body
        /scratch/pauarr3t/build_17657/src/gcc-og12-branch/gcc/fortran/parse.cc:5895
0x6d6d6f parse_executable
        /scratch/pauarr3t/build_17657/src/gcc-og12-branch/gcc/fortran/parse.cc:6051
0x7dafb0 parse_progunit
        /scratch/pauarr3t/build_17657/src/gcc-og12-branch/gcc/fortran/parse.cc:6349
0x7dc670 gfc_parse_file()
        /scratch/pauarr3t/build_17657/src/gcc-og12-branch/gcc/fortran/parse.cc:6872
0x835acf gfc_be_parse_file
        /scratch/pauarr3t/build_17657/src/gcc-og12-branch/gcc/fortran/f95-lang.cc:224
```

On the other hand, if `call bar()` comes before the block, it is parsed correctly.