Allow global variable initialisation only using the compile_item value#1672
Merged
Thirumalai-Shaktivel merged 2 commits intolcompilers:mainfrom Apr 8, 2023
Merged
Conversation
Otherwise, use an assignment statement to initialize the variable.
czgdp1807
reviewed
Apr 7, 2023
Collaborator
There was a problem hiding this comment.
Using your PR, please show the indented ASR for this code.
Collaborator
Author
There was a problem hiding this comment.
(TranslationUnit
(SymbolTable
1
{
_global_symbols:
(Module
(SymbolTable
5
{
_lpython_main_program:
(Function
(SymbolTable
4
{
})
_lpython_main_program
(FunctionType
[]
()
Source
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
[]
.false.
)
[test]
[]
[(=
(Var 5 x)
(FunctionCall
5 test
()
[]
(Integer 4 [])
()
()
)
()
)
(=
(Var 5 j)
(Var 5 i)
()
)]
()
Public
.false.
.false.
),
i:
(Variable
5
i
[]
Local
(IntegerConstant 10 (Integer 4 []))
(IntegerConstant 10 (Integer 4 []))
Default
(Integer 4 [])
Source
Public
Required
.false.
),
j:
(Variable
5
j
[]
Local
()
()
Default
(Integer 4 [])
Source
Public
Required
.false.
),
test:
(Function
(SymbolTable
2
{
_lpython_return_variable:
(Variable
2
_lpython_return_variable
[]
ReturnVar
()
()
Default
(Integer 4 [])
Source
Public
Required
.false.
),
temp:
(Variable
2
temp
[]
Local
()
()
Default
(Integer 4 [])
Source
Public
Required
.false.
)
})
test
(FunctionType
[]
(Integer 4 [])
Source
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
[]
.false.
)
[]
[]
[(=
(Var 2 temp)
(IntegerConstant 0 (Integer 4 []))
()
)
(=
(Var 2 _lpython_return_variable)
(Var 2 temp)
()
)
(Return)]
(Var 2 _lpython_return_variable)
Public
.false.
.false.
),
x:
(Variable
5
x
[]
Local
()
()
Default
(Integer 4 [])
Source
Public
Required
.false.
)
})
_global_symbols
[]
.false.
.false.
),
main_program:
(Program
(SymbolTable
3
{
_lpython_main_program:
(ExternalSymbol
3
_lpython_main_program
5 _lpython_main_program
_global_symbols
[]
_lpython_main_program
Public
)
})
main_program
[_global_symbols]
[(SubroutineCall
3 _lpython_main_program
()
[]
()
)]
)
})
[]
)
certik
approved these changes
Apr 7, 2023
Collaborator
Author
|
Thanks of the approvals! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #1667