浏览代码

* allow taking the address of packed array elements if the element size
is a multiple of 8 bits

git-svn-id: trunk@4576 -

Jonas Maebe 19 年之前
父节点
当前提交
758a1ab5b0
共有 4 个文件被更改,包括 12 次插入3 次删除
  1. 1 0
      .gitattributes
  2. 2 1
      compiler/htypechk.pas
  3. 2 2
      compiler/msg/errore.msg
  4. 7 0
      tests/webtbs/tw7372.pp

+ 1 - 0
.gitattributes

@@ -7285,6 +7285,7 @@ tests/webtbs/tw7161.pp svneol=native#text/plain
 tests/webtbs/tw7195.pp svneol=native#text/plain
 tests/webtbs/tw7227.pp svneol=native#text/plain
 tests/webtbs/tw7276.pp svneol=native#text/plain
+tests/webtbs/tw7372.pp svneol=native#text/plain
 tests/webtbs/ub1873.pp svneol=native#text/plain
 tests/webtbs/ub1883.pp svneol=native#text/plain
 tests/webtbs/uw0555.pp svneol=native#text/plain

+ 2 - 1
compiler/htypechk.pas

@@ -1061,7 +1061,8 @@ implementation
                     not gotvec and
                     not(valid_packed in opts) and
                     (tvecnode(hp).left.resulttype.def.deftype = arraydef) and
-                    (ado_IsBitPacked in tarraydef(tvecnode(hp).left.resulttype.def).arrayoptions) then
+                    (ado_IsBitPacked in tarraydef(tvecnode(hp).left.resulttype.def).arrayoptions) and
+                    (tarraydef(tvecnode(hp).left.resulttype.def).elepackedbitsize mod 8 <> 0) then
                    begin
                      if report_errors then
                        CGMessagePos(hp.fileinfo,parser_e_packed_element_no_var_addr_loop);

+ 2 - 2
compiler/msg/errore.msg

@@ -1079,8 +1079,8 @@ parser_e_array_range_out_of_bounds=03220_E_The range of the array is too large
 % of ptrint.
 parser_e_packed_element_no_var_addr_loop=03221_E_The address cannot be taken of bit packed array elements and record fields, nor can they be used as loop variables
 % If you declare an array or record as \var{packed} in Mac Pascal mode, it will
-% be packed at the bit level (currently only array bit packing is implemented though). This means it becomes impossible to take addresses
-% of individual array elements or records, even if their starting offset happens
+% be packed at the bit level. This means it becomes impossible to take addresses
+% of individual array elements or record fields, in the latter case even if their starting offset happens
 % to be aligned to a byte multiple. For performance reasons, they cannot be
 % used as loop variables either.
 parser_e_packed_dynamic_open_array=03222_E_Dynamic arrays cannot be packed

+ 7 - 0
tests/webtbs/tw7372.pp

@@ -0,0 +1,7 @@
+{$mode macpas}
+program test;
+var r: record field: packed array [0..1] of byte; b:  byte; end;
+procedure p(a: pointer); begin end;
+begin p(@r.field[0]);
+end.
+