Jelajahi Sumber

* fixed internal error with bitpacked arrays of composite types whose
size is not a power of two

git-svn-id: trunk@7596 -

Jonas Maebe 18 tahun lalu
induk
melakukan
65e35ac401
3 mengubah file dengan 45 tambahan dan 1 penghapusan
  1. 1 0
      .gitattributes
  2. 5 1
      compiler/ncgmem.pas
  3. 39 0
      tests/test/tparray20.pp

+ 1 - 0
.gitattributes

@@ -6907,6 +6907,7 @@ tests/test/tparray17.pp svneol=native#text/plain
 tests/test/tparray18.pp svneol=native#text/plain
 tests/test/tparray19.pp svneol=native#text/plain
 tests/test/tparray2.pp svneol=native#text/plain
+tests/test/tparray20.pp svneol=native#text/plain
 tests/test/tparray3.pp svneol=native#text/plain
 tests/test/tparray4.pp svneol=native#text/plain
 tests/test/tparray5.pp svneol=native#text/plain

+ 5 - 1
compiler/ncgmem.pas

@@ -480,8 +480,12 @@ implementation
          byteoffs, bitoffs, alignpower: aint;
          temp : longint;
        begin
+         { only orddefs are bitpacked. Even then we only need special code in }
+         { case the bitpacked *byte size* is not a power of two, otherwise    }
+         { everything can be handled using the the regular array code.        }
          if ((l mod 8) = 0) and
-            ispowerof2(l div 8,temp) then
+            (ispowerof2(l div 8,temp) or
+             not is_ordinal(resultdef)) then
            begin
              update_reference_reg_mul(reg,l div 8);
              exit;

+ 39 - 0
tests/test/tparray20.pp

@@ -0,0 +1,39 @@
+program FatalError_200608051;
+
+   type
+     String32 = string[ 32];
+     String80 = string[ 80];
+     TDS = record
+         ZZStyleName: packed array[0..24] of String32;
+       end;
+     TDSunp = record
+         ZZStyleName: array[0..24] of String32;
+       end;
+     PDS = ^TDS;
+
+   var
+     DV: PDS;
+
+function StyleNameToSongStyleNum (TheSTYName80: String80): longint;
+   var
+     a: Integer;
+begin
+StyleNameToSongStyleNum := 1;
+for A := 1 to 24 do
+   if Pos(DV^.ZZStyleName[a], TheSTYName80) > 0 then
+     begin
+     StyleNameToSongStyleNum := A;
+     exit;
+     end;
+end;
+
+var
+ i: integer;
+begin
+  new(dv);
+  for i := 1 to 24 do
+    tdsunp(dv^).ZZStyleName[i]:='MySong'+chr(i+ord('A'));
+  if (StyleNameToSongStyleNum('MySongF') <> 5) then
+    halt(1);
+end.
+