Improve resolution and compilation of control flow loops and labels#4522
Improve resolution and compilation of control flow loops and labels#4522Islam-Imad wants to merge 2 commits intoRust-GCC:masterfrom
Conversation
|
cc @powerboat9 |
| res += i; | ||
| i += 1; | ||
| if res + i >= 99 { | ||
| break 'calculation; |
There was a problem hiding this comment.
Does continue 'calculation work?
There was a problem hiding this comment.
i don't think because the label now after the loop.
i will check it then ping u for review
There was a problem hiding this comment.
its impossible to create a single label for both continue and break. we have to create two labels one at the start and one at the end. right now i am hacking gcc/go to see how this problem is solved and yeah there is separation.
There was a problem hiding this comment.
this will require more work to be done since we need to modify [loop,while,continue,break] and a lot of testing also. once its ready i will make it open again.
the loop label was placed early in the context and its should be added after the end of the loop. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Fix while label place. gcc/testsuite/ChangeLog: * rust/execute/while-label-break.rs: New test. Signed-off-by: Islam-Imad <islamimad404@gmail.com>
dfc3c94 to
d6e32c3
Compare
|
@powerboat9 this is the core part of the patch, it still not ready. |
9eb024d to
d3de692
Compare
This patch fixes and improves the handling of loop expressions, particularly focusing on `break` and `continue` statements within labeled and nested loops. gcc/rust/ChangeLog: * backend/rust-compile-context.h: Push, Pop, Peek different labels. * backend/rust-compile-expr.cc (CompileExpr::visit): Fix WhileLoopExpr, LoopExpr. (CompileExpr::construct_loop_labels): Construct begin and end labels for loop. * backend/rust-compile-expr.h (RUST_COMPILE_EXPR): Construct loop header. * resolve/rust-default-resolver.cc (DefaultResolver::visit): Fix labels. * resolve/rust-default-resolver.h: Fix labels. * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Fix labels. * resolve/rust-name-resolution-context.cc (NameResolutionContext::insert): Fix labels. (NameResolutionContext::insert_shadowable): Fix labels. (NameResolutionContext::insert_globbed): Fix labels. (NameResolutionContext::scoped): Fix labels. gcc/testsuite/ChangeLog: * rust/execute/cf-break-continue.rs: New test. * rust/execute/cf-label-shadowing.rs: New test. * rust/execute/cf-labeled-break-nested.rs: New test. * rust/execute/cf-labeled-continue-nested.rs: New test. * rust/execute/cf-labeled-loops.rs: New test. * rust/execute/cf-loop-break-continue.rs: New test. * rust/execute/cf-mixed-labeled-unlabeled.rs: New test. * rust/execute/cf-nested-loops.rs: New test. * rust/execute/while-label-break.rs: Renamed. Signed-off-by: Islam-Imad <islamimad404@gmail.com>
d3de692 to
75570ed
Compare
This patch fixes and improves the handling of loop expressions, particularly
focusing on
breakandcontinuestatements within labeled and nested loops.closes #4521
closes #4530