aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/hir
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-11-23 23:09:25 +0000
committerGitHub <noreply@github.com>2021-11-23 23:09:25 +0000
commit717b6da459b26ace9a3c303cfa5e485ff8935709 (patch)
treefad38abf4fc4875a2d3c72336a154d3892a7f1a6 /gcc/rust/hir
parenta41851dfb5bec6f40fd89db01ae75fee557306ee (diff)
parent8b36f2b80ebd0e0304b6df4020b5992640662667 (diff)
downloadgcc-717b6da459b26ace9a3c303cfa5e485ff8935709.zip
gcc-717b6da459b26ace9a3c303cfa5e485ff8935709.tar.gz
gcc-717b6da459b26ace9a3c303cfa5e485ff8935709.tar.bz2
Merge #814
814: Set TREE_ADDRESSABLE when we need to borrow any expression r=philberty a=philberty GCC requires VAR_DECL's and PARAM_DECL's to be marked with TREE_ADDRESSABLE when the declaration will be used in borrow's ('&' getting the address). This takes into account the implicit addresses when we do autoderef in method resolution/operator-overloading. If it is not set we end up in cases like this: ```c i32 main () { i32 a.1; i32 D.86; i32 a; a = 1; a.1 = a; // this is wrong <i32 as AddAssign>::add_assign (&a.1, 2); D.86 = 0; return D.86; } ``` You can see GCC will automatically make a copy of the VAR_DECL resulting bad code-generation. Fixes #804 Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/hir')
-rw-r--r--gcc/rust/hir/tree/rust-hir-item.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/rust/hir/tree/rust-hir-item.h b/gcc/rust/hir/tree/rust-hir-item.h
index 0dd7ac8..99a3c48 100644
--- a/gcc/rust/hir/tree/rust-hir-item.h
+++ b/gcc/rust/hir/tree/rust-hir-item.h
@@ -560,7 +560,7 @@ public:
Type *get_type () { return type.get (); }
- Analysis::NodeMapping &get_mappings () { return mappings; }
+ const Analysis::NodeMapping &get_mappings () const { return mappings; }
};
// Visibility of item - if the item has it, then it is some form of public