Bläddra i källkod

* 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 -

Jonas Maebe 19 år sedan
förälder
incheckning
eb9f00193b
3 ändrade filer med 51 tillägg och 1 borttagningar
  1. 1 0
      .gitattributes
  2. 1 1
      compiler/cgbase.pas
  3. 49 0
      tests/test/cg/tpara2.pp

+ 1 - 0
.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

+ 1 - 1
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

+ 49 - 0
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.