diff options
author | Muhammad Mahad <mahadtxt@gmail.com> | 2023-07-19 20:54:28 +0500 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2023-07-20 09:06:44 +0000 |
commit | 41e7dee1030e1b4813d160b9fd7206fab2302d32 (patch) | |
tree | 7fcf11ed55121def26049ff06725e0d6d4fc0001 /gcc/rust | |
parent | aaeeaa2f7775f6f672aa490884c01217fd1c3f5d (diff) | |
download | gcc-41e7dee1030e1b4813d160b9fd7206fab2302d32.zip gcc-41e7dee1030e1b4813d160b9fd7206fab2302d32.tar.gz gcc-41e7dee1030e1b4813d160b9fd7206fab2302d32.tar.bz2 |
gccrs: [E0268] break or continue used outside of loop
Refactored error description similiar to rustc.
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
refactored and call error function.
gcc/testsuite/ChangeLog:
* rust/compile/break1.rs: Modified to pass test case.
* rust/compile/continue1.rs: likewise.
* rust/compile/break_continue_outside_loop.rs: New test.
Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
Diffstat (limited to 'gcc/rust')
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-expr.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.cc b/gcc/rust/typecheck/rust-hir-type-check-expr.cc index e91da55..3dbe31e 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-expr.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-expr.cc @@ -1277,7 +1277,8 @@ TypeCheckExpr::visit (HIR::BreakExpr &expr) { if (!context->have_loop_context ()) { - rust_error_at (expr.get_locus (), "cannot %<break%> outside of a loop"); + rust_error_at (expr.get_locus (), ErrorCode ("E0268"), + "%<break%> outside of a loop or labeled block"); return; } @@ -1311,8 +1312,8 @@ TypeCheckExpr::visit (HIR::ContinueExpr &expr) { if (!context->have_loop_context ()) { - rust_error_at (expr.get_locus (), - "cannot %<continue%> outside of a loop"); + rust_error_at (expr.get_locus (), ErrorCode ("E0268"), + "%<continue%> outside of a loop"); return; } |