From 0bfce99477fac2901f0e3df075c2773a472bf702 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sun, 26 Aug 2007 11:15:14 +0000 Subject: [PATCH] * fixed bug in ppc jumptable generation for case statements with negative cases caused by wrong automatic type conversion from longint to unsigned tconstexprint (+ test for such jump tables) * fixed darwin/ppc64 jumptables in case of jmptablenorange git-svn-id: trunk@8311 - --- .gitattributes | 1 + compiler/ppcgen/ngppcset.pas | 12 +++++------ tests/test/cg/tcase2.pp | 42 ++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 tests/test/cg/tcase2.pp diff --git a/.gitattributes b/.gitattributes index cec2c3fa9c..c17ad5c142 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6548,6 +6548,7 @@ tests/test/cg/tcalvar7.pp svneol=native#text/plain tests/test/cg/tcalvar8.pp svneol=native#text/plain tests/test/cg/tcalvar9.pp svneol=native#text/plain tests/test/cg/tcase.pp svneol=native#text/plain +tests/test/cg/tcase2.pp svneol=native#text/plain tests/test/cg/tclacla1.pp svneol=native#text/plain tests/test/cg/tclasize.pp svneol=native#text/plain tests/test/cg/tclatype.pp svneol=native#text/plain diff --git a/compiler/ppcgen/ngppcset.pas b/compiler/ppcgen/ngppcset.pas index 363dbd19f2..8c0631e81c 100644 --- a/compiler/ppcgen/ngppcset.pas +++ b/compiler/ppcgen/ngppcset.pas @@ -79,28 +79,28 @@ implementation procedure genitem(list:TAsmList;t : pcaselabel); var - i : aint; + i : TConstExprInt; begin if assigned(t^.less) then genitem(list,t^.less); { fill possible hole } - i:=last.svalue+1; + i:=last+1; while i<=t^._low-1 do begin if (target_info.system<>system_powerpc64_darwin) then list.concat(Tai_const.Create_sym(elselabel)) else list.concat(Tai_const.Create_rel_sym(aitconst_32bit,table,elselabel)); - inc(i); + i:=i+1; end; - i:=t^._low.svalue; + i:=t^._low; while i<=t^._high do begin if (target_info.system<>system_powerpc64_darwin) then list.concat(Tai_const.Create_sym(blocklabel(t^.blockid))) else list.concat(Tai_const.Create_rel_sym(aitconst_32bit,table,blocklabel(t^.blockid))); - inc(i); + i:=i+1; end; last:=t^._high; if assigned(t^.greater) then @@ -131,7 +131,7 @@ implementation else mulfactor:=4; cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_MUL, OS_INT, mulfactor, indexreg); - reference_reset_symbol(href, table, (-aint(min_)) * tcgsize2size[OS_ADDR]); + reference_reset_symbol(href, table, (-aint(min_)) * mulfactor); if (target_info.system<>system_powerpc64_darwin) then begin diff --git a/tests/test/cg/tcase2.pp b/tests/test/cg/tcase2.pp new file mode 100644 index 0000000000..933086c105 --- /dev/null +++ b/tests/test/cg/tcase2.pp @@ -0,0 +1,42 @@ + const + maxsmallint = high(smallint); + { error codes } + grOk = 0; + grNoInitGraph = -1; + grNotDetected = -2; + grFileNotFound = -3; + grInvalidDriver = -4; + grNoLoadMem = -5; + grNoScanMem = -6; + grNoFloodMem = -7; + grFontNotFound = -8; + grNoFontMem = -9; + grInvalidMode = -10; + grError = -11; + grIOerror = -12; + grInvalidFont = -13; + grInvalidFontNum = -14; + grInvalidVersion = -18; + +function GraphErrorMsg(ErrorCode: smallint): string; +Begin + GraphErrorMsg:=''; + case ErrorCode of + grOk,grFileNotFound,grInvalidDriver: exit; + grNoInitGraph: GraphErrorMsg:='Graphics driver not installed'; + grNotDetected: GraphErrorMsg:='Graphics hardware not detected'; + grNoLoadMem,grNoScanMem,grNoFloodMem: GraphErrorMsg := 'Not enough memory for graphics'; + grNoFontMem: GraphErrorMsg := 'Not enough memory to load font'; + grFontNotFound: GraphErrorMsg:= 'Font file not found'; + grInvalidMode: GraphErrorMsg := 'Invalid graphics mode'; + grError: GraphErrorMsg:='Graphics error'; + grIoError: GraphErrorMsg:='Graphics I/O error'; + grInvalidFont,grInvalidFontNum: GraphErrorMsg := 'Invalid font'; + grInvalidVersion: GraphErrorMsg:='Invalid driver version'; + end; +end; + +begin + if GraphErrorMsg(grNoInitGraph) <> 'Graphics driver not installed' then + halt(1); +end.