Issue 202815
Summary [Flang] preprocessor bug with OpenMP sentinels in fixed-format source
Labels flang
Assignees
Reporter scivision
    When fixed-format .F source code with OpenMP directives exists, but OpenMP isn't used, Flang isn't preprocessing the source code correctly. This impacts CMake + Ninja, with the root cause seeming to be a bug in Flang revealed by that common use case.
The bottom of this issue has minimal reproducer code. This occurs across all versions of LLVM Flang I've tried over a couple years.

```sh
src = ""
pp = "flang_mwe-pp.f"

flang -c $src                            # OK
flang -cpp -E $src -o $pp        # emits warning
flang -c $pp                            # errors
```

### Expected

1. direct compile succeeds
2. preprocess succeeds 
3. compile succeds

### Actual

1. Direct compile succeeds.
2. Preprocess gives warning and incorrect syntax generated
3. Compile of preprocessed file fails with unmatched parentheses.

### Problematic  Snippet

```fortran
 call mysub(a, b
!$   &,dummy&
       )
```

The expected source preprocessed is the following. This is like what Gfortran correctly generates.

```fortran
      call mysub(a, b
!$   & ,dummy
     & )
```

## file "flang_mwe.F"

```fortran
     program mwe

 call mysub(a, b
!$   & ,dummy
     & )

      contains

 subroutine mysub(a, b, dummy)
        real :: a, b
        real, optional :: dummy
      end subroutine mysub

      end program
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to