As Fortran 2018 15.5.2.9 point 2, the actual argument and dummy argument
have the same type and type parameters and an external function with
assumed character length may be associated with a dummy argument with
explicit character length. As Fortran 2018 15.5.2.9 point 7, if an
external procedure is used as an actual argument, it can be explicitly
declared to have the EXTERNAL attribute. This supports the external
procedure passed as actual argument with implicit character type, either
explicit character length or assumed character length.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
flang/lib/Optimizer/Builder/Character.cpp | ||
---|---|---|
721–724 | Can you document in the in the header file that len may be a null Value in createCharacterProcedureTuple ? | |
flang/test/Lower/ext-proc-as-actual-argument-1.f90 | ||
20 | I do not think this is a valid program since ext_func is implicitly typed in m, so it is not known to be an "external function with assumed character length" from a Fortran compiler. Ifort actually reject the program. That being said, gfortran seems to support this, and if we do not want to allow this, we should at least block this in semantics. So something needs to be done, thanks for making this patch. @peixin, are you adding support for this case because some existing Fortran code is doing this ? @klausler, I think it is reasonable to support this case, do you agree ? |
flang/test/Lower/ext-proc-as-actual-argument-1.f90 | ||
---|---|---|
20 |
Thanks for correcting me. I think you are right. I forgot to check ifort, which did give the following error: test.f90(7): error #6633: The type of the actual argument differs from the type of the dummy argument. [EXT_FUNC] call sub(ext_func) This seems not to be correct. ext_func is implicitly typed to be the same type as dummy argument.
This test case is not from workloads. When I learn FIR lowering, I take in test cases in classic-flang, gfortran, or randomly searched online, or our internal test cases. And sometimes, I add or delete some components from those test cases. So, this is one mixed test case. |
Addressed the comments.
- Add changes to the header file.
- Change the descriptions in title, summary, and test cases.
character type -> implicit character type
Can you document in the in the header file that len may be a null Value in createCharacterProcedureTuple ?