From ca7510e4477fc37749a79dd6f77019684abbf140 Mon Sep 17 00:00:00 2001 From: Malik Ammar Faisal <binfaisal.ammar@gmail.com> Date: Tue, 5 Dec 2023 19:19:49 +0530 Subject: [PATCH] Fix float parsing in GHC Cmm Lexer Add test case for bug #24224 --- compiler/GHC/Cmm/Lexer.x | 2 +- testsuite/tests/cmm/should_compile/T24224.cmm | 3 +++ testsuite/tests/cmm/should_compile/T24224.stderr | 14 ++++++++++++++ testsuite/tests/cmm/should_compile/all.T | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 testsuite/tests/cmm/should_compile/T24224.cmm create mode 100644 testsuite/tests/cmm/should_compile/T24224.stderr diff --git a/compiler/GHC/Cmm/Lexer.x b/compiler/GHC/Cmm/Lexer.x index 5a422933c203..0c07cbb2cae4 100644 --- a/compiler/GHC/Cmm/Lexer.x +++ b/compiler/GHC/Cmm/Lexer.x @@ -62,7 +62,7 @@ $namechar = [$namebegin $digit] @hexadecimal = $hexit+ @exponent = [eE] [\-\+]? @decimal -@floating_point = @decimal \. @decimal @exponent? | @decimal @exponent +@floating_point = [\-]? (@decimal \. @decimal @exponent? | @decimal @exponent) @escape = \\ ([abfnrt\\\'\"\?] | x $hexit{1,2} | $octit{1,3}) @strchar = ($printable # [\"\\]) | @escape diff --git a/testsuite/tests/cmm/should_compile/T24224.cmm b/testsuite/tests/cmm/should_compile/T24224.cmm new file mode 100644 index 000000000000..748e8ad6021b --- /dev/null +++ b/testsuite/tests/cmm/should_compile/T24224.cmm @@ -0,0 +1,3 @@ +main () { + float64 f1; f1 = (-1.0 :: float64); +} diff --git a/testsuite/tests/cmm/should_compile/T24224.stderr b/testsuite/tests/cmm/should_compile/T24224.stderr new file mode 100644 index 000000000000..9172720b8dfd --- /dev/null +++ b/testsuite/tests/cmm/should_compile/T24224.stderr @@ -0,0 +1,14 @@ + +==================== Output Cmm ==================== +[main() { // [] + { info_tbls: [] + stack_info: arg_space: 8 + } + {offset + _lbl_: + __locVar_::F64 = -1.0 :: W64; + goto c2; + } + }] + + diff --git a/testsuite/tests/cmm/should_compile/all.T b/testsuite/tests/cmm/should_compile/all.T index 45f0b50fcbce..41f32175a8eb 100644 --- a/testsuite/tests/cmm/should_compile/all.T +++ b/testsuite/tests/cmm/should_compile/all.T @@ -12,3 +12,4 @@ test('T16930', normal, makefile_test, ['T16930']) test('T17442', normal, compile, ['']) test('T20725', normal, compile, ['-package ghc']) test('T23610', normal, makefile_test, ['T23610']) +test('T24224', [cmm_src, grep_errmsg(r'(F64.*);', [1])], compile, ['-no-hs-main -ddump-cmm -dsuppress-all -dsuppress-uniques']) -- GitLab