diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-09-23 11:39:06 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-23 11:39:06 +0000 |
commit | 75be04262789545634d6459235b249b01560742c (patch) | |
tree | 74d034b08cf293959f12c97c8a111a8c5755c722 /gcc/rust/backend | |
parent | 98359f20cd2d9268df582ea1ee289e0ea69efcb5 (diff) | |
parent | d68a9eacebb8439ef60b15fe1331d8c007b65bc7 (diff) | |
download | gcc-75be04262789545634d6459235b249b01560742c.zip gcc-75be04262789545634d6459235b249b01560742c.tar.gz gcc-75be04262789545634d6459235b249b01560742c.tar.bz2 |
Merge #687
687: Fix byte char and byte string lexing code r=philberty a=tschwinge
There were two warnings in lexer parse_byte_char and parse_byte_string
code for arches with signed chars:
```
rust-lex.cc: In member function
‘Rust::TokenPtr Rust::Lexer::parse_byte_char(Location)’:
rust-lex.cc:1564:21: warning: comparison is always false due to limited
range of data type [-Wtype-limits]
1564 | if (byte_char > 127)
| ~~~~~~~~~~^~~~~
rust-lex.cc: In member function
‘Rust::TokenPtr Rust::Lexer::parse_byte_string(Location)’:
rust-lex.cc:1639:27: warning: comparison is always false due to limited
range of data type [-Wtype-limits]
1639 | if (output_char > 127)
| ~~~~~~~~~~~~^~~~~
```
The fix would be to cast to an unsigned char before the comparison.
But that is actually wrong, and would produce the following errors
parsing a byte char or byte string:
```
bytecharstring.rs:3:14: error: ‘byte char’ ‘�’ out of range
3 | let _bc = b'\x80';
| ^
bytecharstring.rs:4:14: error: character ‘�’ in byte string out of range
4 | let _bs = b"foo\x80bar";
| ^
```
Both byte chars and byte strings may contain up to \xFF (255)
characters. It is utf-8 chars or strings that can only
Remove the faulty check and add a new testcase bytecharstring.rs
that checks byte chars and strings do accept > 127 hex char
escapes, but utf-8 chars and strings reject such hex char escapes.
---
<http://mid.mail-archive.com/20210921225430.166550-1-mark@klomp.org>
---
Addresses: #336
Fixes: #343, #344
Co-authored-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'gcc/rust/backend')
0 files changed, 0 insertions, 0 deletions