From: Owen Avery <[email protected]>
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 <[email protected]>
---
gcc/rust/resolve/rust-default-resolver.cc | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/gcc/rust/resolve/rust-default-resolver.cc
b/gcc/rust/resolve/rust-default-resolver.cc
index b206c5fc2cd..50625bab956 100644
--- a/gcc/rust/resolve/rust-default-resolver.cc
+++ b/gcc/rust/resolve/rust-default-resolver.cc
@@ -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
--
2.45.2