瀏覽代碼

* fixed check for bitpacked accesses (mantis #24007)

git-svn-id: trunk@23705 -
Jonas Maebe 12 年之前
父節點
當前提交
3cde2b2d84
共有 3 個文件被更改,包括 24 次插入1 次删除
  1. 1 0
      .gitattributes
  2. 2 1
      compiler/nutils.pas
  3. 21 0
      tests/webtbs/tw24007.pp

+ 1 - 0
.gitattributes

@@ -13239,6 +13239,7 @@ tests/webtbs/tw2382.pp svneol=native#text/plain
 tests/webtbs/tw2388.pp svneol=native#text/plain
 tests/webtbs/tw23962.pp svneol=native#text/plain
 tests/webtbs/tw2397.pp svneol=native#text/plain
+tests/webtbs/tw24007.pp svneol=native#text/plain
 tests/webtbs/tw2409.pp svneol=native#text/plain
 tests/webtbs/tw2421.pp svneol=native#text/plain
 tests/webtbs/tw2423.pp svneol=native#text/plain

+ 2 - 1
compiler/nutils.pas

@@ -1029,7 +1029,8 @@ implementation
               { only orddefs and enumdefs are actually bitpacked. Don't consider
                 e.g. an access to a 3-byte record as "bitpacked", since it
                 isn't }
-              (tvecnode(n).left.resultdef.typ in [orddef,enumdef]) and
+              (tvecnode(n).left.resultdef.typ = arraydef) and
+              (tarraydef(tvecnode(n).left.resultdef).elementdef.typ in [orddef,enumdef]) and
               not(tarraydef(tvecnode(n).left.resultdef).elepackedbitsize in [8,16,32,64]);
           subscriptn:
             result:=

+ 21 - 0
tests/webtbs/tw24007.pp

@@ -0,0 +1,21 @@
+var
+    str: bitpacked array [1..6] of 'a'..'z';
+    i: integer;
+    ch: char;
+    error: boolean;
+begin
+    error := false;
+    for i := 1 to 6 do str[i] := chr(ord('a')+i-1);
+    
+    for i := 1 to 6 do begin
+        write('str[i] = ''', str[i], '''; ord(str[2]) = ',ord(str[i]));
+	ch:=str[i]; {if we had used directly str[i] in the expression below, the correct value would have been read}
+	if ch <> chr(ord(str[i])) then
+          begin
+           write(' ==> Bug: chr(',ord(ch),') read, excpected chr(',ord('a')+i-1,')');
+           error:=true;
+          end;
+	writeln;
+    end;
+  halt(ord(error));
+end.