public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8062] gccrs: resolve: Resolve labelled block
@ 2024-01-16 18:15 Arthur Cohen
0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-16 18:15 UTC (permalink / raw)
To: gcc-cvs
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 ())
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-16 18:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 18:15 [gcc r14-8062] gccrs: resolve: Resolve labelled block Arthur Cohen
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).