public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Arthur Cohen <cohenarthur@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8062] gccrs: resolve: Resolve labelled block Date: Tue, 16 Jan 2024 18:15:19 +0000 (GMT) [thread overview] Message-ID: <20240116181519.8612A3858C62@sourceware.org> (raw) https://gcc.gnu.org/g:b195d61877e2d0370e616ebef1fb4378cd47b828 commit r14-8062-gb195d61877e2d0370e616ebef1fb4378cd47b828 Author: Jakub Dupak <dev@jakubdupak.com> Date: Mon Oct 16 15:25:29 2023 +0200 gccrs: resolve: Resolve labelled block gcc/rust/ChangeLog: * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Resolve using loop logic. Signed-off-by: Jakub Dupak <dev@jakubdupak.com> Diff: --- gcc/rust/resolve/rust-ast-resolve-expr.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/gcc/rust/resolve/rust-ast-resolve-expr.cc b/gcc/rust/resolve/rust-ast-resolve-expr.cc index 38d45de32f0..0b6f1b13788 100644 --- a/gcc/rust/resolve/rust-ast-resolve-expr.cc +++ b/gcc/rust/resolve/rust-ast-resolve-expr.cc @@ -303,6 +303,28 @@ ResolveExpr::visit (AST::BlockExpr &expr) resolver->push_new_type_rib (resolver->get_type_scope ().peek ()); resolver->push_new_label_rib (resolver->get_type_scope ().peek ()); + if (expr.has_label ()) + { + auto label = expr.get_label (); + if (label.get_lifetime ().get_lifetime_type () + != AST::Lifetime::LifetimeType::NAMED) + { + rust_error_at (label.get_locus (), + "Labels must be a named lifetime value"); + return; + } + + auto label_name = label.get_lifetime ().get_lifetime_name (); + auto label_lifetime_node_id = label.get_lifetime ().get_node_id (); + resolver->get_label_scope ().insert ( + CanonicalPath::new_seg (label.get_node_id (), label_name), + label_lifetime_node_id, label.get_locus (), false, Rib::ItemType::Label, + [&] (const CanonicalPath &, NodeId, location_t locus) -> void { + rust_error_at (label.get_locus (), "label redefined multiple times"); + rust_error_at (locus, "was defined here"); + }); + } + for (auto &s : expr.get_statements ()) { if (s->is_item ())
reply other threads:[~2024-01-16 18:15 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=20240116181519.8612A3858C62@sourceware.org \ --to=cohenarthur@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).