-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PSyIR] Support for Fortran files without modules? #2201
Comments
I'm not sure I understand. A FileContainer can contain multiple program units. In Fortran these could be a program, a module, a subroutine, a function (and some data stuff we don't support). So a subroutine would be a Routine within a FileContainer. If we only have one program unit then it is also valid to not have a FileContainer at all. I'm pretty sure there are lots of examples in our tests that only use subroutines, functions or programs and have no modules. |
That's all quite true. However, we don't put Symbols for the various routines into a SymbolTable and therefore when one routine calls another one, it can't find a Symbol for it. (@LonelyCat124 hit this while trying to workaround a statement function by introducing a new FUNCTION into the source file instead.) |
Ah, I see. Yes, it makes sense for Routine and Container symbols to be added to parent Container symbol tables including a FileContainer. |
A simple standalone fail case again:
|
This may also be required to fix #2156 fully, but I'm not sure on the source code that needs that change. |
I tried to see if I could have a quite look at how to add a SymbolTable to a FileContainer but I think this will be more complex than just that. I think fparser2 relies on there being a I guess the bit I can't really find is where the FileContainer is created for non-programs - for One option would be in
and remove the check from the frontend. This at least handles the case for #2156, but I'm not sure if it will break anything else Does this seem like a reasonable option or is there something elsewhere that this could break? Edit:
|
#2575 fixes this behaviour for Subroutines, but leaves programs and (more importantly) Modules as symbol-less. This raised a question more generally on how we should handle modules, as I don't think now there is a symbol + interface setup to handle this kind of behaviour as a file:
PSyclone will likely parse and output this file, however i think my_mod will just be an unresolved module and the type of x will be unknown, despite all the information being available in the FileContainer. To handle this we would need some sort of symbol for Modules in a FileContainer (as I don't think any of the current ContainerSymbol strategies handles this case) and when importing modules we should first check the subroutine's symboltable (which should recurse upwards to the FileContainer) for the relevant module/container symbol alongside this. It could be needed for inlining or something else like this. I don't think we've come across an immediate use-case for this, but I expect its something we might run into at some point during NG-ARCH |
(Towards #2201) Implementation enabling FileContainer's to have information about routines outside of modules.
In processing Socrates, @LonelyCat124 has been encountering source files that just contain program units (subroutines) without a module. At the minute, PSyclone does not create/populate a SymbolTable for a FileContainer - this is explicitly rejected by the Fortran backend.
We need to consider how we want to support 'bare' program units. It seems sensible that we would populate a SymbolTable associated with the FileContainer but I can't remember why we don't do that. Perhaps @sergisiso, @rupertford and @hiker have some thoughts?
The text was updated successfully, but these errors were encountered: