Browse Source

* allow deref of loop variable

git-svn-id: trunk@981 -
peter 20 years ago
parent
commit
62972054c4
3 changed files with 19 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 1 0
      compiler/htypechk.pas
  3. 17 0
      tests/webtbs/tw4308.pp

+ 1 - 0
.gitattributes

@@ -6187,6 +6187,7 @@ tests/webtbs/tw4247.pp svneol=native#text/plain
 tests/webtbs/tw4253.pp svneol=native#text/plain
 tests/webtbs/tw4260.pp svneol=native#text/plain
 tests/webtbs/tw4277.pp svneol=native#text/plain
+tests/webtbs/tw4308.pp svneol=native#text/plain
 tests/webtbs/tw4336.pp svneol=native#text/plain
 tests/webtbs/ub1873.pp svneol=native#text/plain
 tests/webtbs/ub1883.pp svneol=native#text/plain

+ 1 - 0
compiler/htypechk.pas

@@ -1143,6 +1143,7 @@ implementation
                      begin
                        { loop counter? }
                        if not(Valid_Const in opts) and
+                          not gotderef and
                           (vo_is_loop_counter in tabstractvarsym(tloadnode(hp).symtableentry).varoptions) then
                          CGMessage1(parser_e_illegal_assignment_to_count_var,tloadnode(hp).symtableentry.realname);
                        { derefed pointer }

+ 17 - 0
tests/webtbs/tw4308.pp

@@ -0,0 +1,17 @@
+{ Source provided for Free Pascal Bug Report 4308 }
+{ Submitted by "Olle" on  2005-08-22 }
+{ e-mail: [email protected] }
+program loop_var_assgn;
+
+	procedure ZeroBlock (startAddr: PtrUInt; length: SizeUInt);
+
+		var
+			i: PtrUInt;
+
+	begin
+		for i := startAddr to startAddr + length - 1 do
+			PByte(i)^ := 0;
+	end;
+
+begin
+end.