]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Visit constant items without expressions properly
authorOwen Avery <powerboat9.gamer@gmail.com>
Thu, 29 Feb 2024 01:19:04 +0000 (20:19 -0500)
committerP-E-P <32375388+P-E-P@users.noreply.github.com>
Thu, 16 May 2024 10:55:42 +0000 (10:55 +0000)
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 c54cabad2e5dc7b27952945375a104258f502770..ca831840298edda5f8e508abf8089ff2bef8c454 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