-
-
Notifications
You must be signed in to change notification settings - Fork 129
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
[Fortran] Handle variable names starting with underscore #2806
[Fortran] Handle variable names starting with underscore #2806
Conversation
to support Fortran syntax Design, - Prepend "v" for variable names - Prepend "f" for function names
Perfect. Is there a test that this now enables to compile that fails in master? We need to figure out how to test this. One option is to enable this pass in the "fortran" backend by default, which is the one used by the cmake test suite. And then add a test that would otherwise fail, but now works. |
Yup, for that we have to apply passes. I came across this issue while testing the All the variables staring with We need to apply passes for the Fortran backend, right? Currently we don't. |
We should apply some passes. I think we should apply this pass in the Fortran backend (in Do you want to try enabling it and see if some new test passes? That would be a good test for this PR. |
Consider the following example: program expr2
implicit none
integer :: x(2)
x = (2+3)*5
end program I get, program expr2
implicit none
integer(4), dimension(2) :: x
x = (2 + 3)*5
end program expr2
program expr2
implicit none
integer(4) :: v__1_t
integer(4) :: v__libasr_created_scalar_auxiliary_variable
integer(4), dimension(2) :: x
v__libasr_created_scalar_auxiliary_variable = (2 + 3)*5
v__1_t = lbound(x, 1) - 1
do while (v__1_t + 1 <= ubound(x, 1))
v__1_t = v__1_t + 1
x(v__1_t) = v__libasr_created_scalar_auxiliary_variable
end do
end program expr2 The following also works program expr2
implicit none
integer(4) :: __1_t
integer(4) :: __libasr_created_scalar_auxiliary_variable
integer(4), dimension(2) :: x
__libasr_created_scalar_auxiliary_variable = (2 + 3)*5
do __1_t = lbound(x, 1), ubound(x, 1)
x(__1_t) = __libasr_created_scalar_auxiliary_variable
end do
end program expr2 |
Enabling the passes requires most of the changes from this PR: #2747, so let's merge that and then work on this. |
898a9b4
to
962adb0
Compare
Ok, go ahead and rebase this. Important: the I think the application of this PR is when we are printing the ASR using |
I see. In that case, I think we won't be able to test this PR changes using Should I test it using |
962adb0
to
ff5fc1f
Compare
ff5fc1f
to
dd92ff8
Compare
Ready for review. |
@@ -392,6 +392,9 @@ namespace LCompilers { | |||
apply_default_passes = false; | |||
} | |||
|
|||
void use_fortran_passes() { | |||
_user_defined_passes.push_back("unique_symbols"); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean the unique_symbols
pass is always applied even without the --apply-fortran-mangling
option? Is this only for the --backend-fortran
, or also --dump-all-passes-fortran
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The unique_symbols
passes are applied only when we pass some options like: https://github.com/lfortran/lfortran/pull/2806/files#diff-0b1b8d6c43c5a0e83ce23cda4c34fde853efebc4baa0cb1676e9f4298f82c532R505-R516
It is used by both --show-fortran
and --backend=fortran
.
--dump-all-passes-fortran
dumps all the passes output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I think this is fine then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine.
Thanks for the review! |
No description provided.