llvm / llvm-project

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

IGNORE_TKR directive with gfortran #51494

Open 41bca00d-a81e-4b66-b614-ae4e2b0f1c87 opened 3 years ago

41bca00d-a81e-4b66-b614-ae4e2b0f1c87 commented 3 years ago
Bugzilla Link 52152
Version unspecified
OS All
Attachments a reproducer to evidence the issue
CC @jeanPerier,@kiranktp,@sscalpone

Extended Description

The attached conftest.f90 program can be used in order to evidence the issue.

gfortran -c conftest.f90

should work (it can issue a warning related to an type/interface mismatch, but that can be ignored).

Now the same file fails to compile with flang resulting into an error in the gfortran backend

Error: Rank mismatch in argument 'buffer' at (1) (rank-1 and scalar) flang_unparsed_file_e29b812d7687_0.f90:36:19:

What happens is the 'buffer' dummy argument of the 'foo' subroutine has the following directive

   !GCC$ ATTRIBUTES NO_ARG_CHECK :: buffer

This is GCC specific (as the !GCC$ sentinel implies), and is simply stripped by flang. Consequently, the flang-processed file contains no such directive and hence gfortran fails.

flang offers a similar directive !DIR$ IGNORE_TKR buffer that is passed as-is to gfortran.

Unfortunately, gfortran does not understand this directive and the compilation fails.

Of course, one option is to have the fine GNU folks update gfortran to support this directive.

Other options at the flang level could be to

Will you be willing to consider doing something about that at the flang level?

41bca00d-a81e-4b66-b614-ae4e2b0f1c87 commented 3 years ago

FWIW, the issue was initially reported at https://github.com/open-mpi/ompi/issues/9481