diff options
author | Philip Herron <herron.philip@googlemail.com> | 2020-06-13 20:28:28 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2020-11-28 21:13:16 +0000 |
commit | 15280699c13f799f25bfc95656415c0ec2c1b901 (patch) | |
tree | ab67df319d15d12a9c626a03a0cd9827b54c2a77 /gcc/rust/analysis | |
parent | 84ed897a9b5dcb28cc0cf8a85296e3628b2f0e17 (diff) | |
download | gcc-15280699c13f799f25bfc95656415c0ec2c1b901.zip gcc-15280699c13f799f25bfc95656415c0ec2c1b901.tar.gz gcc-15280699c13f799f25bfc95656415c0ec2c1b901.tar.bz2 |
Struct record compilation and type resolution
Diffstat (limited to 'gcc/rust/analysis')
-rw-r--r-- | gcc/rust/analysis/rust-type-resolution.cc | 17 | ||||
-rw-r--r-- | gcc/rust/analysis/rust-type-resolution.h | 2 |
2 files changed, 18 insertions, 1 deletions
diff --git a/gcc/rust/analysis/rust-type-resolution.cc b/gcc/rust/analysis/rust-type-resolution.cc index 03f3d27..b8baabb 100644 --- a/gcc/rust/analysis/rust-type-resolution.cc +++ b/gcc/rust/analysis/rust-type-resolution.cc @@ -690,9 +690,24 @@ TypeResolution::visit (AST::Function &function) void TypeResolution::visit (AST::TypeAlias &type_alias) {} + void TypeResolution::visit (AST::StructStruct &struct_item) -{} +{ + for (auto &field : struct_item.fields) + { + if (!isTypeInScope (field.field_type.get (), + Linemap::unknown_location ())) + { + rust_fatal_error (Linemap::unknown_location (), + "unknown type in struct field"); + return; + } + } + + structsPerBlock.Insert (struct_item.struct_name, &struct_item); +} + void TypeResolution::visit (AST::TupleStruct &tuple_struct) {} diff --git a/gcc/rust/analysis/rust-type-resolution.h b/gcc/rust/analysis/rust-type-resolution.h index 1155267..e9fec83 100644 --- a/gcc/rust/analysis/rust-type-resolution.h +++ b/gcc/rust/analysis/rust-type-resolution.h @@ -224,6 +224,8 @@ private: bool isTypeInScope (AST::Type *type, Location locus); Scope<AST::Function *> functionScope; + Scope<AST::LetStmt *> localsPerBlock; + Scope<AST::StructStruct *> structsPerBlock; }; } // namespace Analysis |