* don't allow taking the address of packed record fields

* don't allow using packed record fields as loopvars

git-svn-id: trunk@4509 -
This commit is contained in:
Jonas Maebe 2006-08-27 11:08:39 +00:00
parent ca92dd416a
commit 340e2257f3
4 changed files with 39 additions and 0 deletions

2
.gitattributes vendored
View File

@ -6153,6 +6153,7 @@ tests/test/tparray8.pp svneol=native#text/plain
tests/test/tparray9.pp svneol=native#text/plain
tests/test/tpftch1.pp svneol=native#text/plain
tests/test/tprec1.pp svneol=native#text/plain
tests/test/tprec10.pp svneol=native#text/plain
tests/test/tprec2.pp svneol=native#text/plain
tests/test/tprec3.pp svneol=native#text/plain
tests/test/tprec4.pp svneol=native#text/plain
@ -6160,6 +6161,7 @@ tests/test/tprec5.pp svneol=native#text/plain
tests/test/tprec6.pp svneol=native#text/plain
tests/test/tprec7.pp svneol=native#text/plain
tests/test/tprec8.pp svneol=native#text/plain
tests/test/tprec9.pp svneol=native#text/plain
tests/test/tprocext.pp svneol=native#text/plain
tests/test/tprocvar1.pp svneol=native#text/plain
tests/test/tprocvar2.pp svneol=native#text/plain

View File

@ -1087,6 +1087,15 @@ implementation
end;
subscriptn :
begin
{ only check first (= outermost) subscriptn }
if not gotsubscript and
not(valid_packed in opts) and
is_packed_record_or_object(tsubscriptnode(hp).left.resulttype.def) then
begin
if report_errors then
CGMessagePos(hp.fileinfo,parser_e_packed_element_no_var_addr_loop);
exit;
end;
gotsubscript:=true;
{ loop counter? }
if not(Valid_Const in opts) and

15
tests/test/tprec10.pp Normal file
View File

@ -0,0 +1,15 @@
{ %fail }
{$mode tp}
type
tr = bitpacked record
a,b: 0..7;
end;
var
r: tr;
begin
for r.a := 0 to 4 do
writeln;
end.

13
tests/test/tprec9.pp Normal file
View File

@ -0,0 +1,13 @@
{ %fail }
type
tr = bitpacked record
a,b: 0..7;
end;
var
r: tr;
p: pointer;
begin
p := @r.b;
end.