From d217a459aac3cc2ec2792045ea7f27bc042bc789 Mon Sep 17 00:00:00 2001 From: Pierre Muller Date: Wed, 12 Oct 2022 21:24:28 +0100 Subject: [PATCH] Fix bug report #39952. * compiler/aggas.pas: Avoid use of .long for 64bit constant for targets that automatically insert alignments. + tests/webtbs/tw39952.pp: New test from bug report 39952. --- compiler/aggas.pas | 5 ++- tests/webtbs/tw39952.pp | 70 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 tests/webtbs/tw39952.pp diff --git a/compiler/aggas.pas b/compiler/aggas.pas index 62684bdb22..96884186b2 100644 --- a/compiler/aggas.pas +++ b/compiler/aggas.pas @@ -1050,7 +1050,10 @@ implementation internalerror(200404292); if not(target_info.system in systems_aix) then begin - writer.AsmWrite(ait_const2str[aitconst_32bit]); + if (target_info.system in use_ua_elf_systems) then + writer.AsmWrite(ait_ua_elf_const2str[aitconst_32bit]) + else + writer.AsmWrite(ait_const2str[aitconst_32bit]); if target_info.endian = endian_little then begin writer.AsmWrite(tostr(longint(lo(tai_const(hp).value)))); diff --git a/tests/webtbs/tw39952.pp b/tests/webtbs/tw39952.pp new file mode 100644 index 0000000000..0f606c427a --- /dev/null +++ b/tests/webtbs/tw39952.pp @@ -0,0 +1,70 @@ + +const + REC_SIZE=3; + +type + tinst = packed record + x : word; + b : byte; + rec : array[1..REC_SIZE] of int64; + end; + +const + x_val = 45634; + b_val = 56; + rec1_val = $123456; + rec2_val = $DCBA87654321; + rec3_val = $ADEFCB4567; + t : tinst = ( + x : x_val; + b : b_val; + rec : (rec1_val,rec2_val,rec3_val) + ); + + +var + i : longint; +const + has_errors : boolean = false; + +begin + writeln('t.x=',t.x); + writeln('t.b=',t.b); + for i:=1 to REC_SIZE do + writeln('t.rec[',i,']=',t.rec[i]); + if (t.x <> x_val) then + begin + writeln('t.x field is wrong'); + has_errors:=true; + end; + + if (t.b <> b_val) then + begin + writeln('t.b field is wrong'); + has_errors:=true; + end; + + if (t.rec[1] <> rec1_val) then + begin + writeln('t.rec[1] field is wrong'); + has_errors:=true; + end; + + if (t.rec[2] <> rec2_val) then + begin + writeln('t.rec2 field is wrong'); + has_errors:=true; + end; + + if (t.rec[3] <> rec3_val) then + begin + writeln('t.rec[3] field is wrong'); + has_errors:=true; + end; + + if has_errors then + begin + writeln('Wrong code is generated'); + halt(1); + end; +end.