nvfortran compiler supports using INTENT attributes for non-dummy arguments. For example, for local variables.
This change adds a -fnon-arg-intent flag that enables such behavior in flang.
Paths
| Differential D123113
[Flang] Add `INTENT` for non-dummy arguments extension AbandonedPublic Authored by unterumarmung on Apr 5 2022, 3:09 AM.
Details Summary nvfortran compiler supports using INTENT attributes for non-dummy arguments. For example, for local variables. This change adds a -fnon-arg-intent flag that enables such behavior in flang.
Diff Detail
Unit TestsFailed Event Timelineunterumarmung retitled this revision from [Flang] Add `INTENT` for non-dummy arguments extension nvfortran compiler supports using INTENT attributes for non-dummy arguments. For example, for local variables. to [Flang] Add `INTENT` for non-dummy arguments extension. Comment ActionsFixed revision description This comment was removed by unterumarmung. Comment Actions Hi! Thanks for this patch, and for your interest in contributing to Flang! I will leave it to somebody more experienced to accept the patch -- I am not familiar with this extension, and am not aware on what grounds we decide which extensions to support. I hope that my suggestions and questions can be useful anyway. We keep a list of supported extensions in flang/docs/Extensions.md Please add this extension there. And please also explain its behaviour a bit. I wonder about the behaviour. Is INTENT for non-dummies allowed-but-ignored, or does it change the semantics? For example, is an INTENT(IN) variable supposed to be read-only? And what about combining SAVE, INTENT(OUT)? Or PARAMETER, INTENT(INOUT)? I would also appreciate tests for this behaviour, e.g., a check that modifying an INTENT(IN) non-dummy is allowed or disallowed, as desired.
Comment Actions @ekieri, hello! Thank you for the comment, it is really helpful! Actually, nvfortran compiler forbids to use INTENT attribute on local variables, even though a "mod" file can be generated. It generates a severe error like the one below and there's no way to ignore the severe errors, if I understand correctly. NVFORTRAN-S-0134-Illegal attribute - intent specified for nondummy argument bar2 (test.f90: 3) But the reason why I filed the patch was that nvfortran allows to use any kind of INTENT attribute for a local variable that marked as RESULT one for a function: function foo() result(bar) integer, intent(out) :: bar end function foo nvfortran does not generate any message for this code, not even a warning. So, it looks like a bug in the compiler, not a feature or extension and this should not be supported in flang, I think. Comment Actions Ok, good. Then please abandon this revision (Add Action... down by the comment box), so that its status is clear to everybody. Cheers!
Revision Contents
Diff 420437 clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/include/flang/Common/Fortran-features.h
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Semantics/check-declarations.cpp
flang/test/Driver/driver-help-hidden.f90
flang/test/Driver/driver-help.f90
flang/test/Driver/frontend-forwarding.f90
|
Feel free to use my suggestion literally or to work out something better, whichever you prefer.