]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Visit constant items without expressions properly
authorOwen Avery <powerboat9.gamer@gmail.com>
Thu, 29 Feb 2024 01:19:04 +0000 (20:19 -0500)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 17 Mar 2025 15:35:23 +0000 (16:35 +0100)
gcc/rust/ChangeLog:

* resolve/rust-default-resolver.cc
(DefaultResolver::visit):
Verify constant item has expression before attempting to visit
the later.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/resolve/rust-default-resolver.cc

index b206c5fc2cdae3b73ed857c31c3387b5d45e12dc..50625bab956f7e9926eb0f8847a439d75c81a853 100644 (file)
@@ -449,13 +449,16 @@ DefaultResolver::visit (AST::EnumItemDiscriminant &item)
 void
 DefaultResolver::visit (AST::ConstantItem &item)
 {
-  auto expr_vis = [this, &item] () {
-    item.get_expr ().accept_vis (*this);
-    visit (item.get_type ());
-  };
+  if (item.has_expr ())
+    {
+      auto expr_vis = [this, &item] () {
+       item.get_expr ().accept_vis (*this);
+       visit (item.get_type ());
+      };
 
-  // FIXME: Why do we need a Rib here?
-  ctx.scoped (Rib::Kind::Item, item.get_node_id (), expr_vis);
+      // FIXME: Why do we need a Rib here?
+      ctx.scoped (Rib::Kind::Item, item.get_node_id (), expr_vis);
+    }
 }
 
 void