diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-05-02 21:26:10 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-02 21:26:10 +0000 |
commit | ca722fe423bdd8c7895a40aac0410b2646917805 (patch) | |
tree | 52ca965213514c45d7143acff72d9d21f090b4e6 /gcc/rust/backend/rust-compile-implitem.cc | |
parent | 5aec7cbfa560440801dfd0b26e408ab6fb692ed6 (diff) | |
parent | 7e576d70b6a1065bf31c37380a8e39354d961cd6 (diff) | |
download | gcc-ca722fe423bdd8c7895a40aac0410b2646917805.zip gcc-ca722fe423bdd8c7895a40aac0410b2646917805.tar.gz gcc-ca722fe423bdd8c7895a40aac0410b2646917805.tar.bz2 |
Merge #1197
1197: Support recursive coercion sites r=philberty a=philberty
There are two changes are part of this PR one where we update the address_expression
helper to take a ptrtype tree. Since the default build_address_expr_loc was automatically
building a pointer type of the TREE_TYPE of the operand which is not correct since we
sometimes want REFERENCE_TYPES instead of POINTER_TYPES.
The 2nd commit enhances the coercion_site code to recursively walk the tree and their
types to handle coercions to dyn traits or do array bounds checking etc. This gets rid of
the get_root hack used and cleans up the code in general.
Fixes #1146
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-implitem.cc')
-rw-r--r-- | gcc/rust/backend/rust-compile-implitem.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/rust/backend/rust-compile-implitem.cc b/gcc/rust/backend/rust-compile-implitem.cc index 9dc6d14..c13556a 100644 --- a/gcc/rust/backend/rust-compile-implitem.cc +++ b/gcc/rust/backend/rust-compile-implitem.cc @@ -68,7 +68,10 @@ CompileTraitItem::visit (HIR::TraitItemFunc &func) { ctx->insert_function_decl (fntype, lookup); } - reference = address_expression (lookup, ref_locus); + reference + = address_expression (lookup, + build_pointer_type (TREE_TYPE (lookup)), + ref_locus); return; } } @@ -95,7 +98,9 @@ CompileTraitItem::visit (HIR::TraitItemFunc &func) func.get_outer_attrs (), func.get_locus (), func.get_block_expr ().get (), canonical_path, fntype, function.has_return_type ()); - reference = address_expression (fndecl, ref_locus); + reference + = address_expression (fndecl, build_pointer_type (TREE_TYPE (fndecl)), + ref_locus); } } // namespace Compile |