From eb9f00193bee2baaffa848f69fcd2a54fc09ef12 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Thu, 6 Apr 2006 22:09:25 +0000 Subject: [PATCH] * return OS_NO from int_cgsize() for sizes which are not a power of 2 (fixes crash in tests/test/cg/tpara2.pp for ppc, does not break i386) git-svn-id: trunk@3159 - --- .gitattributes | 1 + compiler/cgbase.pas | 2 +- tests/test/cg/tpara2.pp | 49 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 tests/test/cg/tpara2.pp diff --git a/.gitattributes b/.gitattributes index 2ba4f5bce4..30ca228894 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5559,6 +5559,7 @@ tests/test/cg/tnot.pp svneol=native#text/plain tests/test/cg/tobjsiz2.pp svneol=native#text/plain tests/test/cg/tobjsize.pp svneol=native#text/plain tests/test/cg/tpara1.pp svneol=native#text/plain +tests/test/cg/tpara2.pp svneol=native#text/plain tests/test/cg/tprintf.pp svneol=native#text/plain tests/test/cg/traise1.pp svneol=native#text/plain tests/test/cg/traise2.pp svneol=native#text/plain diff --git a/compiler/cgbase.pas b/compiler/cgbase.pas index 63e8e4b3a5..01fe26633e 100644 --- a/compiler/cgbase.pas +++ b/compiler/cgbase.pas @@ -562,7 +562,7 @@ implementation function int_cgsize(const a: aint): tcgsize;{$ifdef USEINLINE}inline;{$endif} const size2cgsize : array[0..8] of tcgsize = ( - OS_NO,OS_8,OS_16,OS_32,OS_32,OS_64,OS_64,OS_64,OS_64 + OS_NO,OS_8,OS_16,OS_NO,OS_32,OS_NO,OS_NO,OS_NO,OS_64 ); begin if a>8 then diff --git a/tests/test/cg/tpara2.pp b/tests/test/cg/tpara2.pp new file mode 100644 index 0000000000..7f9c54066f --- /dev/null +++ b/tests/test/cg/tpara2.pp @@ -0,0 +1,49 @@ +type + sint16 = smallint; + uint16 = word; + + Point = record + case SInt16 of + 0: ( + v: SInt16; + h: SInt16; + ); + 1: ( + vh: array [0..1] of SInt16; + ); + end; + + Rect = record + case SInt16 of + 0: ( + top: SInt16; + left: SInt16; + bottom: SInt16; + right: SInt16; + ); + 1: ( + topLeft: Point; + botRight: Point; + ); + end; + + RGBColor = record + red: UInt16; + { magnitude of red component } + green: UInt16; + { magnitude of green component } + blue: UInt16; + { magnitude of blue component } + end; + +function test(r: Rect; c1, c2: RGBColor): Rect; +begin + test:= r; +end; + +var + r: rect; + c1,c2: rgbcolor; +begin + test(r,c1,c2); +end.