]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: ast: Fix char literal ICE
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Tue, 4 Apr 2023 09:54:59 +0000 (11:54 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:28:43 +0000 (18:28 +0100)
The code was attempting to convert a char to an integer by parsing it
instead of taking it's raw value.

gcc/rust/ChangeLog:

* ast/rust-ast-tokenstream.cc (TokenStream::visit): Fix ICE.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ast/rust-ast-tokenstream.cc

index b248aeedea3ea576b27599b37d5e438d219847e9..4a7107fbbbb9bb8063d9c8ac5ae2d1980f8d22f0 100644 (file)
@@ -789,8 +789,10 @@ TokenStream::visit (Literal &lit, Location locus)
   switch (lit.get_lit_type ())
     {
     case Literal::LitType::CHAR:
-      tokens.push_back (Rust::Token::make_char (
-       locus, Codepoint (static_cast<uint32_t> (std::stoul (value)))));
+      tokens.push_back (
+       Rust::Token::make_char (locus,
+                               // TODO: Change this to support utf-8 properly
+                               Codepoint (static_cast<uint32_t> (value[0]))));
       break;
     case Literal::LitType::STRING:
       tokens.push_back (Rust::Token::make_string (locus, std::move (value)));