aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-item.cc
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2022-08-26 08:44:02 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2022-08-26 08:44:02 +0200
commitfc82b68cc1ee2778f2bfc53c5de47e5b36ac8b7c (patch)
tree95454db7a9799f2ad2c16205fbc305e7ff7a09c0 /gcc/rust/backend/rust-compile-item.cc
parentff7d6bfed2e7bc08fba1cc456daf464e6176dd46 (diff)
downloadgcc-fc82b68cc1ee2778f2bfc53c5de47e5b36ac8b7c.zip
gcc-fc82b68cc1ee2778f2bfc53c5de47e5b36ac8b7c.tar.gz
gcc-fc82b68cc1ee2778f2bfc53c5de47e5b36ac8b7c.tar.bz2
backend: Add overflow checks to every arithmetic operation
Diffstat (limited to 'gcc/rust/backend/rust-compile-item.cc')
-rw-r--r--gcc/rust/backend/rust-compile-item.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-item.cc b/gcc/rust/backend/rust-compile-item.cc
index ceba51c..96c4e7f 100644
--- a/gcc/rust/backend/rust-compile-item.cc
+++ b/gcc/rust/backend/rust-compile-item.cc
@@ -160,6 +160,9 @@ CompileItem::visit (HIR::Function &function)
function.get_mappings ().get_nodeid (), &canonical_path);
rust_assert (ok);
+ if (function.get_qualifiers ().is_const ())
+ ctx->push_const_context ();
+
tree fndecl
= compile_function (ctx, function.get_function_name (),
function.get_self_param (),
@@ -169,6 +172,9 @@ CompileItem::visit (HIR::Function &function)
function.get_definition ().get (), canonical_path,
fntype, function.has_function_return_type ());
reference = address_expression (fndecl, ref_locus);
+
+ if (function.get_qualifiers ().is_const ())
+ ctx->pop_const_context ();
}
void