Ver código fonte

Merged revisions 7596,7598-7599,7605 via svnmerge from
svn+ssh://[email protected]/FPC/svn/fpc/trunk

........
r7596 | jonas | 2007-06-08 11:11:08 +0200 (Fri, 08 Jun 2007) | 3 lines

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

........
r7598 | jonas | 2007-06-08 15:44:57 +0200 (Fri, 08 Jun 2007) | 2 lines

* added missing {$mode macpas}

........
r7599 | jonas | 2007-06-08 15:53:01 +0200 (Fri, 08 Jun 2007) | 3 lines

* fixed another IE with indexing bitpacked arrays of composite types,
this time with constant rather than variable indices

........
r7605 | jonas | 2007-06-09 19:05:35 +0200 (Sat, 09 Jun 2007) | 3 lines

* added packrecords statement so the test compiles on all systems regardless
of the default packrecords value

........

git-svn-id: branches/fixes_2_2@7615 -

Jonas Maebe 18 anos atrás
pai
commit
23fbc2ea00
4 arquivos alterados com 67 adições e 2 exclusões
  1. 2 0
      .gitattributes
  2. 8 2
      compiler/ncgmem.pas
  3. 42 0
      tests/test/tparray20.pp
  4. 15 0
      tests/test/tparray21.pp

+ 2 - 0
.gitattributes

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

+ 8 - 2
compiler/ncgmem.pas

@@ -480,8 +480,12 @@ implementation
          byteoffs, bitoffs, alignpower: aint;
          byteoffs, bitoffs, alignpower: aint;
          temp : longint;
          temp : longint;
        begin
        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
          if ((l mod 8) = 0) and
-            ispowerof2(l div 8,temp) then
+            (ispowerof2(l div 8,temp) or
+             not is_ordinal(resultdef)) then
            begin
            begin
              update_reference_reg_mul(reg,l div 8);
              update_reference_reg_mul(reg,l div 8);
              exit;
              exit;
@@ -777,7 +781,9 @@ implementation
               end;
               end;
               if not(is_packed_array(left.resultdef)) or
               if not(is_packed_array(left.resultdef)) or
                  ((mulsize mod 8 = 0) and
                  ((mulsize mod 8 = 0) and
-                  ispowerof2(mulsize div 8,temp)) then
+                  (ispowerof2(mulsize div 8,temp) or
+                   { only orddefs are bitpacked }
+                   not is_ordinal(resultdef))) then
                 begin
                 begin
                   inc(location.reference.offset,
                   inc(location.reference.offset,
                     bytemulsize*tordconstnode(right).value);
                     bytemulsize*tordconstnode(right).value);

+ 42 - 0
tests/test/tparray20.pp

@@ -0,0 +1,42 @@
+{$mode macpas}
+{$packrecords 4}
+
+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.
+

+ 15 - 0
tests/test/tparray21.pp

@@ -0,0 +1,15 @@
+{$mode macpas}
+
+program FatalError_200301231;
+   type
+     note_name_type = packed array[0..17] of string[2];
+   var
+     nn: note_name_type;
+     s: string[ 80];
+begin
+   nn[1]:= 'x';
+   s:=concat( 'y', nn[ 1]);
+   if (s <> 'yx') then
+     halt(1);
+end.
+