diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2024-02-28 20:19:04 -0500 |
---|---|---|
committer | P-E-P <32375388+P-E-P@users.noreply.github.com> | 2024-05-16 10:55:42 +0000 |
commit | c7687ef1f7a9d2683bb45dcbf547b42aae856075 (patch) | |
tree | fe7017283b1c6814c1da5b7aa9733ab997d6adfd /gcc | |
parent | 1c52754ee19991bc07c4023cad777a6a894bb64f (diff) | |
download | gcc-c7687ef1f7a9d2683bb45dcbf547b42aae856075.zip gcc-c7687ef1f7a9d2683bb45dcbf547b42aae856075.tar.gz gcc-c7687ef1f7a9d2683bb45dcbf547b42aae856075.tar.bz2 |
Visit constant items without expressions properly
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>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/resolve/rust-default-resolver.cc | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/gcc/rust/resolve/rust-default-resolver.cc b/gcc/rust/resolve/rust-default-resolver.cc index c54caba..ca83184 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 |