-
Couldn't load subscription status.
- Fork 25
1260 cfg semantic domain lite integrate as analyzer #1741
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
1260 cfg semantic domain lite integrate as analyzer #1741
Conversation
| label = "{Block2| goback\l}" | ||
| ] | ||
| Block0 -> Block1 | ||
| Block1 -> Block2 |
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 code contains an error:
Line 4[12,12] <30, Error, Semantics> - Semantic error: Statement ' go to b' located at line 10, column 12 prevents this PERFORM statement to reach its exit.
IBM Compiler only reports a warning, because the code can still be executed.
Execution will produce an abend U4038, because there is no goback at the end of paragraph b. But if there is a goback, the execution is ok.
So shall we create an error or a warning? I think it should be a warning to behave like IBM compiler.
We can then ask our users if they want an error. In this case the error could be set as parameter of CLI/LSP (like parameter diagnostic.checkEndAlignment)
For the CFG : the goback statement can never be reached, but the dot file shows otherwise.
Line Block1 -> Block2 should not appear in the dot file.
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 to turn this diagnostic into a Warning. Edit: done 916f17c.
About the Block1 to Block2 edge, this edge is created while building the graph. It is only after resolving all GOTO/ALTER/PERFORM that we could find out which part of the code is unreachable or not.
The graph is built as to contain all and every possible paths but we need a post-build analysis to actually find which parts are unreachable. Do you confirm @mayanje ?
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.
In my opinion this case the error is that the perform goes out of paragraph a and thus the goback will never be executed, but this a consequence of the abend U4038 and not the control flow. So you are right to stay iso with IBM Compiler, it is a warning (a Severe Warning).
The unreachability of the goback instruction can be detected by an abstract interpretation in this case, because we must detect that finally we will face an abend U4038.
| Block8 -> Block9 | ||
| Block9 -> Block10 | ||
|
|
||
| } |
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.
Is it normal that there's no Block11 declared?
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 don't get the meaning of your question 😕
During parsing, the CFG builder will create new block each time a new sentence is encountered and also when branching is required. After building, blocks may be cloned if they participate in a PERFORM target group. When generating the dot file however, only blocks connected to the root are considered. Some blocks created during parsing may finally not appear in the graph.
Do you think the resulting graph is wrong/missing some elements ?
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 was checking the tests from the .dot files directly, I was wondering about the numbering as I couldn't see any block11 when block10 and block12 were declared. It's just that it's the only block number that doesn't appear in the .dot file although other empty blocks are still declared (block2, block4...). You probably gave me the answer just above so I'll look again at the graphs. Thanks.
| Block28 -> Block29 | ||
| Block29 -> Block30 | ||
| Block30 -> Block31 | ||
|
|
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.
As discussed together from analysis on perform loops.
Graph doesn't show loop on block30 for Perform until (as for Perform varying in PerfromNested0)
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.
This bug shall be adressed in the main PR. I'll copy your comment there.
This PR focuses on actual integration of CFG/DFA as a new kind of analyzer instead of using
NodeDispatcherlisteners (which are now totally removed).Diagnostics need to be improved
add test for "out-of-bounds performs"add test for incorrect order of paragraphs in a PERFORM THRU (issue New diagnostic : The second paragraph/section of a "PERFORM THRU" statement must be defined after the first paragraph/section #1448)add test for invalid ALTER statements