-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gccrs: [E0571] break with argument in non-loop loop
Refactored error message similiar to rustc & called error function. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): refactored error message & called error function. gcc/testsuite/ChangeLog: * rust/compile/break2.rs: Modified file to pass test case. * rust/compile/break_with_value_inside_loop.rs: New test. Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
- Loading branch information
1 parent
b4d1406
commit 5bd6eb3
Showing
3 changed files
with
19 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
14 changes: 14 additions & 0 deletions
14
gcc/testsuite/rust/compile/break_with_value_inside_loop.rs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// https://doc.rust-lang.org/error_codes/E0571.html | ||
#![allow(unused)] | ||
fn main() { | ||
let mut i = 1; | ||
fn satisfied(n: usize) -> bool { | ||
n % 23 == 0 | ||
} | ||
let result = while true { | ||
if satisfied(i) { | ||
break 2 * i; // { dg-error "can only .break. with a value inside a .loop. block" } | ||
} | ||
i += 1; | ||
}; | ||
} |