diff options
author | Mark Wielaard <mark@klomp.org> | 2021-07-25 14:12:42 +0200 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2021-07-25 14:54:13 +0200 |
commit | df2b3b15dc95d5d74f6a630ee84296fb5b76c03f (patch) | |
tree | cefadc8af71ae3c09ff21b59e873ffffe1430adc /gcc/rust/rust-gcc.cc | |
parent | 314b62ec787abdf320fcca8ceb09b8c9bcf72512 (diff) | |
download | gcc-df2b3b15dc95d5d74f6a630ee84296fb5b76c03f.zip gcc-df2b3b15dc95d5d74f6a630ee84296fb5b76c03f.tar.gz gcc-df2b3b15dc95d5d74f6a630ee84296fb5b76c03f.tar.bz2 |
Support byte and byte string literals
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].
Diffstat (limited to 'gcc/rust/rust-gcc.cc')
-rw-r--r-- | gcc/rust/rust-gcc.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc index 74a8b52..23a91ad 100644 --- a/gcc/rust/rust-gcc.cc +++ b/gcc/rust/rust-gcc.cc @@ -333,6 +333,8 @@ public: Bexpression *wchar_constant_expression (wchar_t c); + Bexpression *char_constant_expression (char c); + Bexpression *boolean_constant_expression (bool val); Bexpression *real_part_expression (Bexpression *bcomplex, Location); @@ -1557,6 +1559,13 @@ Gcc_backend::wchar_constant_expression (wchar_t c) return this->make_expression (ret); } +Bexpression * +Gcc_backend::char_constant_expression (char c) +{ + tree ret = build_int_cst (this->char_type ()->get_tree (), c); + return this->make_expression (ret); +} + // Make a constant boolean expression. Bexpression * |