public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] Preserve inside_loop context when compiling match Date: Wed, 8 Jun 2022 12:42:42 +0000 (GMT) [thread overview] Message-ID: <20220608124242.75BFC386CE73@sourceware.org> (raw) https://gcc.gnu.org/g:0472834ddf177038d343b193acab70b2859656f8 commit 0472834ddf177038d343b193acab70b2859656f8 Author: David Faust <david.faust@oracle.com> Date: Tue May 3 15:12:24 2022 -0700 Preserve inside_loop context when compiling match Diff: --- gcc/rust/typecheck/rust-hir-type-check-expr.h | 2 +- gcc/testsuite/rust/execute/torture/match_loop1.rs | 51 +++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.h b/gcc/rust/typecheck/rust-hir-type-check-expr.h index 5633751c5a0..f1dff2cb0f2 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-expr.h +++ b/gcc/rust/typecheck/rust-hir-type-check-expr.h @@ -1027,7 +1027,7 @@ public: // check the kase type TyTy::BaseType *kase_block_ty - = TypeCheckExpr::Resolve (kase.get_expr ().get (), false); + = TypeCheckExpr::Resolve (kase.get_expr ().get (), inside_loop); kase_block_tys.push_back (kase_block_ty); } diff --git a/gcc/testsuite/rust/execute/torture/match_loop1.rs b/gcc/testsuite/rust/execute/torture/match_loop1.rs new file mode 100644 index 00000000000..d3aab6bc0bf --- /dev/null +++ b/gcc/testsuite/rust/execute/torture/match_loop1.rs @@ -0,0 +1,51 @@ +// { dg-output "E::One\nE::Two\nbreak!\n" } + +extern "C" { + fn printf(s: *const i8, ...); +} + +enum E { + One, + Two, + Other +} + +fn foo () { + let mut x = E::One; + + loop { + match x { + E::One => { + let a = "E::One\n\0"; + let b = a as *const str; + let c = b as *const i8; + printf (c); + + x = E::Two; + } + E::Two => { + let a = "E::Two\n\0"; + let b = a as *const str; + let c = b as *const i8; + printf (c); + + x = E::Other; + } + _ => { + let a = "break!\n\0"; + let b = a as *const str; + let c = b as *const i8; + printf (c); + + break; + } + } + } +} + + +fn main () -> i32 { + foo (); + + 0 +}
reply other threads:[~2022-06-08 12:42 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220608124242.75BFC386CE73@sourceware.org \ --to=tschwinge@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).