Re: [PATCH] Fix byte char and byte string lexing code

2021-09-22 Thread Thomas Schwinge
Hi Mark!

On 2021-09-22T00:54:30+0200, Mark Wielaard  wrote:
> 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)
>   |   ~~^

That's .

> 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)
>   |   ^

That's .

Both these related to 
"GCC '--enable-bootstrap' build".

> 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 [truncated here -- but 
> I understand what you mean]

I think this does match my thoughts in
.

> 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.
> ---
>
> https://code.wildebeest.org/git/user/mjw/gccrs/commit/?h=bytecharstring

Thanks, that's now: 
"Fix byte char and byte string lexing code".


Grüße
 Thomas
-
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 
München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas 
Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht 
München, HRB 106955
-- 
Gcc-rust mailing list
Gcc-rust@gcc.gnu.org
https://gcc.gnu.org/mailman/listinfo/gcc-rust


Re: [PATCH] Fix byte char and byte string lexing code

2021-09-22 Thread Mark Wielaard
Hi Thomas,

On Wed, Sep 22, 2021 at 11:48:56AM +0200, Thomas Schwinge wrote:
> That's .
> [...] 
> That's .

Ah, sorry, I don't really track the github issues and had missed
those. But good to see the analysis matches.

> Both these related to 
> "GCC '--enable-bootstrap' build".

To make --enable-bootstrap possible (wow, that takes a long time...)
you'll also need:
https://gcc.gnu.org/pipermail/gcc-rust/2021-September/000178.html
https://code.wildebeest.org/git/user/mjw/gccrs/commit/?h=rust-mangle-unreachable

With this and that patch applied there are no more warnings building
the rust frontend, so a --enable-bootstrap (-Werror) build completes
successfully.

> > https://code.wildebeest.org/git/user/mjw/gccrs/commit/?h=bytecharstring
> 
> Thanks, that's now: 
> "Fix byte char and byte string lexing code".

Thanks,

Mark

-- 
Gcc-rust mailing list
Gcc-rust@gcc.gnu.org
https://gcc.gnu.org/mailman/listinfo/gcc-rust