llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.96k stars 11.54k forks source link

[Flang][Application=BigDFT] Error in Fortran parsing/preprocessor when compiling with OpenMP enabled #64128

Closed kiranchandramohan closed 1 year ago

kiranchandramohan commented 1 year ago

A parse/preprocessor error was observed while compiling Fortran code containing an include directive in a subroutine.

Source ab.f90

subroutine simple()
  implicit none
  !$ include 'inc.f90'
end subroutine simple

inc.f90

print *, "Hello"

Error

flang-new  ab.f90  -fopenmp
error: Could not parse ab.f90
./ab.f90:3:14: error: expected '('
    !$ include 'inc.f90'
               ^
./ab.f90:3:6: in the context: statement function definition
    !$ include 'inc.f90'
       ^
./ab.f90:3:6: in the context: declaration construct
    !$ include 'inc.f90'
       ^
./ab.f90:2:3: in the context: specification part
    implicit none
    ^
./ab.f90:1:1: in the context: SUBROUTINE subprogram
  subroutine simple()
  ^

Note: This was observed while compiling BigDFT (https://bigdft.org/?i=1, https://gitlab.com/l_sim/bigdft-suite/-/blame/devel/futile/dicts/callbacks.f90#L71)

llvmbot commented 1 year ago

@llvm/issue-subscribers-flang-frontend

klausler commented 1 year ago

EDIT: Never mind, I see that this is an OpenMP conditional compilation line. Will make INCLUDE work for such.

llvmbot commented 1 year ago

@llvm/issue-subscribers-bug

klausler commented 1 year ago

Fix is in test; if you need it this week, let me know and I'll expedite it.

kiranchandramohan commented 1 year ago

Thanks @klausler. This is not urgent.

klausler commented 1 year ago

https://reviews.llvm.org/D156759

llvmbot commented 1 year ago

@llvm/issue-subscribers-openmp