-
Notifications
You must be signed in to change notification settings - Fork 31
Description
We know that both NEMO and NEMOVAR override (different) Fortran intrinsics. PSyclone simply does not handle this situation correctly at present.
When attempting to match an intrinsic function call, fparser does check that it hasn't already got a Symbol defined with the same name.
If it has, then it does not match:
https://github.com/stfc/fparser/blob/eee1f4fd40b0b339e6190b709b853227e5b2d857/src/fparser/two/Fortran2003.py#L12526-L12536
However, if an application is using wildcard imports then there will be no Symbol already defined and fparser will match an intrinsic function call unless we are lucky and the overridden version has an argument count inconsistent with the standard-defined version. If fparser does match an intrinsic function then PSyclone simply converts this into an IntrinsicCall node - fparser2._intrinsic_handler does not check for any existing Symbols of the same name:
PSyclone/src/psyclone/psyir/frontend/fparser2.py
Line 4994 in c9c20b1
| intrinsic = IntrinsicCall.Intrinsic[node.items[0].string.upper()] |
A relatively simple(?) first step would be to extend fparser2._intrinsic_handler to attempt to lookup a symbol with the same name as the intrinsic. If it finds one, then it would have to call the appropriate handler (e.g. Call or ArrayReference). This would work provided:
- The symbol is not a transitive import;
- We have the originating module listed in
RESOLVE_IMPORTSin the transformation script.