From edd59b43f3d33a0f57be9e39182447e2ec67fe3c Mon Sep 17 00:00:00 2001 From: Maxim Logaev Date: Wed, 24 Jul 2024 17:39:52 +0300 Subject: [PATCH] Fixed hex numbers for integer literal Description: Hex numbers are now treated like decimal numbers. That is, the hex value is now signed. Example (for "int"): -10 (decimal) is now -0x0000000A (hex) rather than 0xFFFFFFF6 (hex). However, when overflowing for hex, the integer literal type does not expand to "double" as it does with decimal representation. Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/IACNIB Testing: run tests: parser, ets-cts, ets-func-tests. Signed-off-by: Maxim Logaev --- ets2panda/lexer/ETSLexer.h | 4 ++-- ets2panda/test/parser/ets/enum19-expected.txt | 6 +++--- ets2panda/test/parser/ets/enum19.ets | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ets2panda/lexer/ETSLexer.h b/ets2panda/lexer/ETSLexer.h index 341c800aca..6640793dc4 100644 --- a/ets2panda/lexer/ETSLexer.h +++ b/ets2panda/lexer/ETSLexer.h @@ -49,10 +49,10 @@ public: } try { - ScanNumberLeadingZeroImpl(); + ScanNumberLeadingZeroImpl(); } catch (...) { Rewind(savedLexerPosition); - ScanNumberLeadingZeroImpl(); + ScanNumberLeadingZeroImpl(); } if ((GetToken().flags_ & TokenFlags::NUMBER_BIGINT) != 0) { diff --git a/ets2panda/test/parser/ets/enum19-expected.txt b/ets2panda/test/parser/ets/enum19-expected.txt index 278789677e..0a758bb0b1 100644 --- a/ets2panda/test/parser/ets/enum19-expected.txt +++ b/ets2panda/test/parser/ets/enum19-expected.txt @@ -126,11 +126,11 @@ "loc": { "start": { "line": 19, - "column": 10 + "column": 11 }, "end": { "line": 19, - "column": 20 + "column": 14 } } }, @@ -141,7 +141,7 @@ }, "end": { "line": 19, - "column": 20 + "column": 14 } } } diff --git a/ets2panda/test/parser/ets/enum19.ets b/ets2panda/test/parser/ets/enum19.ets index 1746f7bcf9..4c389923c7 100644 --- a/ets2panda/test/parser/ets/enum19.ets +++ b/ets2panda/test/parser/ets/enum19.ets @@ -16,5 +16,5 @@ enum InvalidInitTypeEnum { Red, Green = -1, - Blue = 0xFFFFFFFF + Blue = -0x1 } -- Gitee