diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-01-13 21:14:28 +0000 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2021-01-16 14:07:50 +0000 |
commit | d96e1594dd378078987900819afc611bd0db19b0 (patch) | |
tree | 7105c8abfaaabe2dbd997aee37e13fe0bed860c4 /gcc/rust/resolve/rust-ast-resolve.cc | |
parent | 05b9f235566d7d361709c5bc44e7c36598515946 (diff) | |
download | gcc-d96e1594dd378078987900819afc611bd0db19b0.zip gcc-d96e1594dd378078987900819afc611bd0db19b0.tar.gz gcc-d96e1594dd378078987900819afc611bd0db19b0.tar.bz2 |
This brings in resolution and type checking of the unit-type.
It is possible to assign and declare variables of unit-type which
translate down to zero sized void_type_node.
More work is needed to handle array and ADT types using unit-type
when emiting gimple. The name+type resolution should be generic enough.
Diffstat (limited to 'gcc/rust/resolve/rust-ast-resolve.cc')
-rw-r--r-- | gcc/rust/resolve/rust-ast-resolve.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve.cc b/gcc/rust/resolve/rust-ast-resolve.cc index d6eed93..e0b4f3a 100644 --- a/gcc/rust/resolve/rust-ast-resolve.cc +++ b/gcc/rust/resolve/rust-ast-resolve.cc @@ -113,7 +113,7 @@ Resolver::insert_builtin_types (Rib *r) Linemap::predeclared_location ()); } -std::vector<AST::TypePath *> & +std::vector<AST::Type *> & Resolver::get_builtin_types () { return builtins; @@ -160,6 +160,16 @@ Resolver::generate_builtins () MKBUILTIN_TYPE ("bool", builtins, rbool); MKBUILTIN_TYPE ("f32", builtins, f32); MKBUILTIN_TYPE ("f64", builtins, f64); + + // unit type () + TyTy::UnitType *unit_tyty = new TyTy::UnitType (mappings->get_next_hir_id ()); + std::vector<std::unique_ptr<AST::Type> > elems; + AST::TupleType *unit_type + = new AST::TupleType (std::move (elems), Linemap::predeclared_location ()); + builtins.push_back (unit_type); + tyctx->insert_builtin (unit_tyty->get_ref (), unit_type->get_node_id (), + unit_tyty); + set_unit_type_node_id (unit_type->get_node_id ()); } void |