diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-01-18 17:57:22 +0000 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2021-01-20 09:59:22 +0000 |
commit | 12f7bd0fc4e9ab4e98869b5265aea6bacfb31d03 (patch) | |
tree | aaff0986f81394b83e8536b68a18bcd48ecb9484 /gcc/rust/backend | |
parent | 6e2acd529fcfa43368f7ea8209cc5e6b88d2bd79 (diff) | |
download | gcc-12f7bd0fc4e9ab4e98869b5265aea6bacfb31d03.zip gcc-12f7bd0fc4e9ab4e98869b5265aea6bacfb31d03.tar.gz gcc-12f7bd0fc4e9ab4e98869b5265aea6bacfb31d03.tar.bz2 |
Support struct initializers using Identifiers
This resolves each identifier for its respective field. It includes fixes
for the TypeResolver to print errors instead of asserts where we loose
decent debug info.
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r-- | gcc/rust/backend/rust-compile-struct-field-expr.h | 2 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile.cc | 10 |
2 files changed, 12 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-struct-field-expr.h b/gcc/rust/backend/rust-compile-struct-field-expr.h index 0e54281..0a16f6a 100644 --- a/gcc/rust/backend/rust-compile-struct-field-expr.h +++ b/gcc/rust/backend/rust-compile-struct-field-expr.h @@ -40,6 +40,8 @@ public: void visit (HIR::StructExprFieldIndexValue &field); + void visit (HIR::StructExprFieldIdentifier &field); + private: CompileStructExprField (Context *ctx) : HIRCompileBase (ctx), translated (nullptr) diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc index cb6272f..ce6d827 100644 --- a/gcc/rust/backend/rust-compile.cc +++ b/gcc/rust/backend/rust-compile.cc @@ -234,5 +234,15 @@ CompileStructExprField::visit (HIR::StructExprFieldIndexValue &field) translated = CompileExpr::Compile (field.get_value (), ctx); } +void +CompileStructExprField::visit (HIR::StructExprFieldIdentifier &field) +{ + // we can make the field look like an identifier expr to take advantage of + // existing code + HIR::IdentifierExpr expr (field.get_mappings (), field.get_field_name (), + field.get_locus ()); + translated = CompileExpr::Compile (&expr, ctx); +} + } // namespace Compile } // namespace Rust |