diff options
author | Philip Herron <philip.herron@embecosm.com> | 2022-01-05 18:31:03 +0000 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2022-01-06 10:48:10 +0000 |
commit | 507dbac06d845af87e488dcb1f66390b4ca12de3 (patch) | |
tree | 98ee1dbd06ff29564271a18929ed092f9e158875 /gcc/rust/hir | |
parent | 69f6be3ee483c9895b4b5187a44b3e1c8be2ba63 (diff) | |
download | gcc-507dbac06d845af87e488dcb1f66390b4ca12de3.zip gcc-507dbac06d845af87e488dcb1f66390b4ca12de3.tar.gz gcc-507dbac06d845af87e488dcb1f66390b4ca12de3.tar.bz2 |
Add overflow checking on LiteralExpression
This checks that the literal value is within the bounds of their respective
types. I have ommited code fixing the other issue in the bug report that
overflow/max_val integers should be saturated to infinity when cast to
REAL_TYPE's this seems like something we really should have documentation
to reference in the code as to why this is the correct Rust behaviour.
Addresses #635
Diffstat (limited to 'gcc/rust/hir')
-rw-r--r-- | gcc/rust/hir/tree/rust-hir-expr.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/rust/hir/tree/rust-hir-expr.h b/gcc/rust/hir/tree/rust-hir-expr.h index 6784550..c1495d4 100644 --- a/gcc/rust/hir/tree/rust-hir-expr.h +++ b/gcc/rust/hir/tree/rust-hir-expr.h @@ -95,7 +95,8 @@ public: void accept_vis (HIRFullVisitor &vis) override; - Literal *get_literal () { return &literal; } + Literal &get_literal () { return literal; } + const Literal &get_literal () const { return literal; } protected: /* Use covariance to implement clone function as returning this object rather |