diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-01-25 17:03:36 +0000 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2021-01-27 10:42:25 +0000 |
commit | 8578c61be5061fab91fe679a15fd68ab5fad987c (patch) | |
tree | f09524d5f8bf17fab00618ef7e8e98fd905a557e /gcc/rust/backend/rust-compile-var-decl.h | |
parent | 854aad3b58e747cad3e46b522c9ef765bdfadca4 (diff) | |
download | gcc-8578c61be5061fab91fe679a15fd68ab5fad987c.zip gcc-8578c61be5061fab91fe679a15fd68ab5fad987c.tar.gz gcc-8578c61be5061fab91fe679a15fd68ab5fad987c.tar.bz2 |
Add mutablity checks and left hand size assignee checker
In order to assign to a name we must ensure the LHS is a valid expression
to assign to. This leads onto actually checking if this is a mutable
declaration or not.
Once these checks pass the name resolver we can in GIMPLE create immutable
types for these declarations to help with optimization.
Fixes #77
Diffstat (limited to 'gcc/rust/backend/rust-compile-var-decl.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-var-decl.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-var-decl.h b/gcc/rust/backend/rust-compile-var-decl.h index cf73820..06ea5a9 100644 --- a/gcc/rust/backend/rust-compile-var-decl.h +++ b/gcc/rust/backend/rust-compile-var-decl.h @@ -54,6 +54,9 @@ public: void visit (HIR::IdentifierPattern &pattern) { + if (!pattern.is_mut) + translated_type = ctx->get_backend ()->immutable_type (translated_type); + translated = ctx->get_backend ()->local_variable (fndecl, pattern.variable_ident, translated_type, NULL /*decl_var*/, |