diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-07-25 21:13:35 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-25 21:13:35 +0000 |
commit | 4447dba7c8a9126a9701ddc8ae02cc1425e1fa77 (patch) | |
tree | cefadc8af71ae3c09ff21b59e873ffffe1430adc /gcc/rust/backend/rust-compile-expr.h | |
parent | 314b62ec787abdf320fcca8ceb09b8c9bcf72512 (diff) | |
parent | df2b3b15dc95d5d74f6a630ee84296fb5b76c03f (diff) | |
download | gcc-4447dba7c8a9126a9701ddc8ae02cc1425e1fa77.zip gcc-4447dba7c8a9126a9701ddc8ae02cc1425e1fa77.tar.gz gcc-4447dba7c8a9126a9701ddc8ae02cc1425e1fa77.tar.bz2 |
Merge #594
594: Support byte and byte string literals r=philberty a=dkm
A byte literal is an u8 created as a ascii char or hex escape
e.g. b'X'. A byte string literal is a string created from ascii or
hex chars. bytes are represented as u8 and byte strings as str (with
just ascii < 256 chars), but it should really be &'static [u8; n].
Co-authored-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'gcc/rust/backend/rust-compile-expr.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h index dff4712..fa6a539 100644 --- a/gcc/rust/backend/rust-compile-expr.h +++ b/gcc/rust/backend/rust-compile-expr.h @@ -278,7 +278,14 @@ public: } return; - case HIR::Literal::STRING: { + case HIR::Literal::BYTE: { + char c = literal_value->as_string ().c_str ()[0]; + translated = ctx->get_backend ()->char_constant_expression (c); + } + return; + + case HIR::Literal::STRING: + case HIR::Literal::BYTE_STRING: { auto base = ctx->get_backend ()->string_constant_expression ( literal_value->as_string ()); translated |