aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/rust-gcc.cc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-01-21 14:02:16 +0000
committerPhilip Herron <herron.philip@googlemail.com>2021-01-26 11:59:23 +0000
commitbe371b9f49e0c4fd7752cad6708fed8b1f2719a3 (patch)
tree4cd49a36ce274aa268a816ab8c72abda84a08393 /gcc/rust/rust-gcc.cc
parentbe10fafbb6e06aeb8a818e404ac512f2f1bfce30 (diff)
downloadgcc-be371b9f49e0c4fd7752cad6708fed8b1f2719a3.zip
gcc-be371b9f49e0c4fd7752cad6708fed8b1f2719a3.tar.gz
gcc-be371b9f49e0c4fd7752cad6708fed8b1f2719a3.tar.bz2
Add backend support to create immutable types
GCC uses qualified types to create const immutability.
Diffstat (limited to 'gcc/rust/rust-gcc.cc')
-rw-r--r--gcc/rust/rust-gcc.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index 748aa5a..6f8dc46 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -173,6 +173,8 @@ public:
Btype *pointer_type (Btype *);
+ Btype *immutable_type (Btype *);
+
Btype *function_type (const Btyped_identifier &,
const std::vector<Btyped_identifier> &,
const std::vector<Btyped_identifier> &, Btype *,
@@ -848,6 +850,18 @@ Gcc_backend::pointer_type (Btype *to_type)
return this->make_type (type);
}
+// Get immutable type
+
+Btype *
+Gcc_backend::immutable_type (Btype *base)
+{
+ tree type_tree = base->get_tree ();
+ if (type_tree == error_mark_node)
+ return this->error_type ();
+ tree constified = build_qualified_type (type_tree, TYPE_QUAL_CONST);
+ return this->make_type (constified);
+}
+
// Make a function type.
Btype *