-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Description
flangversion is:flang version 21.0.0git (https://github.com/llvm/llvm-project.git a3dc77c00a012bb613cb08e669dab4fadf88e935).- Reduced test case:
! foo.f90
program main
print *, __FILE__, __LINE__
endflanginvocation is:flang -x f95-cpp-input -c foo.f90.- Expected behavior is: The code compiles successfully.
- Actual behavior: Compilation aborts with the following error:
error: Semantic errors foo.f90
foo.f90:4:12: error: No explicit type declared for '__file__'
print *, __FILE__, __LINE__
^^^^^^^^
foo.f90:4:22: error: No explicit type declared for '__line__'
print *, __FILE__, __LINE__
^^^^^^^^
-
Analysis: It appears that
flangdoes not correctly interpret-x f95-cpp-input. This option should enable preprocessing (equivalent toflang -x f95 -cpp -c foo.f90), but instead, it is not recognized correctly. Additionally,flangdoes not properly recognize the following language modes:-x f95should map to whatever the file extension is or command-line option is passed.-x f77should map to-ffixed-form.-x f77-cpp-inputshould map to-x f77 -cpp(i.e.,-ffixed-form -cpp).
flangincorrectly applies-ffixed-formwhen given-x f95(see [flang] Flang fails to interpret-x f95-cpp-inputand related modes #127617 (comment)):$ cat foo.f90 program main print *, __FILE__, __LINE__ end $ flang -x f95 -cpp foo.f90 foo.f90:1:1: warning: Character in fixed-form label field must be a digit program main ^ foo.f90:2:3: warning: Character in fixed-form label field must be a digit print *, __FILE__, __LINE__ ^ foo.f90:3:1: warning: Character in fixed-form label field must be a digit end ^
gfortrancorrectly applies-ffixed-form -cppwhen given-x f77-cpp-input:$ cat foo.f90 #ifdef __FILE__ subroutine foo() end #endif $ gfortran -x f77-cpp-input foo.f90 foo.f90:2:2: 2 | subroutine foo() | 1 Error: Non-numeric character in statement label at (1) foo.f90:3:2: 3 | end | 1 Error: Non-numeric character in statement label at (1)
-
Request: The
-xflag should correctly recognize and apply the appropiate Fortran language modes. This is required to compile codes such as MESA (MESA's Makefile) withflang. It is unclear whetherflangaims to mimicgfortran's behavior in its driver. However, sinceflangexplicitly supportsf95andf95-cpp-input, we believe it should at least align withgfortran's behavior for this option.