Browse Source

* don't try to bitpack arrays of non-ordinals (mantis #36157)

git-svn-id: trunk@43187 -
Jonas Maebe 5 years ago
parent
commit
33c4a5dda7
3 changed files with 19 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 1 0
      compiler/ngtcon.pas
  3. 17 0
      tests/webtbs/tw36157.pp

+ 1 - 0
.gitattributes

@@ -17841,6 +17841,7 @@ tests/webtbs/tw35982.pp svneol=native#text/pascal
 tests/webtbs/tw36013.pp svneol=native#text/pascal
 tests/webtbs/tw36013.pp svneol=native#text/pascal
 tests/webtbs/tw3612.pp svneol=native#text/plain
 tests/webtbs/tw3612.pp svneol=native#text/plain
 tests/webtbs/tw36156.pp svneol=native#text/plain
 tests/webtbs/tw36156.pp svneol=native#text/plain
+tests/webtbs/tw36157.pp svneol=native#text/plain
 tests/webtbs/tw3617.pp svneol=native#text/plain
 tests/webtbs/tw3617.pp svneol=native#text/plain
 tests/webtbs/tw3619.pp svneol=native#text/plain
 tests/webtbs/tw3619.pp svneol=native#text/plain
 tests/webtbs/tw3621.pp svneol=native#text/plain
 tests/webtbs/tw3621.pp svneol=native#text/plain

+ 1 - 0
compiler/ngtcon.pas

@@ -1250,6 +1250,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
           end
           end
         { packed array constant }
         { packed array constant }
         else if is_packed_array(def) and
         else if is_packed_array(def) and
+                (def.elementdef.typ in [orddef,enumdef]) and
                 ((def.elepackedbitsize mod 8 <> 0) or
                 ((def.elepackedbitsize mod 8 <> 0) or
                  not ispowerof2(def.elepackedbitsize div 8,i)) then
                  not ispowerof2(def.elepackedbitsize div 8,i)) then
           begin
           begin

+ 17 - 0
tests/webtbs/tw36157.pp

@@ -0,0 +1,17 @@
+program WatchesValuePrg;
+
+type
+  TEnum = (EnVal1, EnVal2, EnVal3, EnVal4);
+  TSet = set of TEnum;
+  TBitPackSetArray2 = bitpacked array [0..1, 0..2] of TSet;
+const
+  gcBitPackSetArray2 : TBitPackSetArray2 = (([EnVal3, EnVal1], [], [EnVal3]), ([],[EnVal1,EnVal2],[EnVal1]));
+
+begin
+  if gcBitPackSetArray2[0,0]<>[EnVal3, EnVal1] then
+    halt(1);
+  if gcBitPackSetArray2[0,2]<>[EnVal3] then
+    halt(2);
+  if gcBitPackSetArray2[1,1]<>[EnVal1,EnVal2] then
+    halt(3);
+end.