2
0
Эх сурвалжийг харах

* also check for properties passed to read(ln) when reading integers
different from the native size, or when reading enums (because those
are handled via a temp internally -> regular var parameter checks
were not automatically performed)

git-svn-id: trunk@7398 -

Jonas Maebe 18 жил өмнө
parent
commit
497df2bb37

+ 1 - 0
.gitattributes

@@ -7319,6 +7319,7 @@ tests/webtbf/tw8777d.pp svneol=native#text/plain
 tests/webtbf/tw8777e.pp svneol=native#text/plain
 tests/webtbf/tw8777h.pp svneol=native#text/plain
 tests/webtbf/tw8777j.pp svneol=native#text/plain
+tests/webtbf/tw8777k.pp svneol=native#text/plain
 tests/webtbf/tw8780a.pp svneol=native#text/plain
 tests/webtbf/tw8780b.pp svneol=native#text/plain
 tests/webtbf/tw8780c.pp svneol=native#text/plain

+ 6 - 0
compiler/ninl.pas

@@ -624,6 +624,12 @@ implementation
                 end;
               if special_handling then
                 begin
+                  { since we're not going to pass the parameter as var-parameter }
+                  { to the read function, manually check whether the parameter   }
+                  { can be used as var-parameter (e.g., whether it isn't a       }
+                  { property)                                                    }
+                  valid_for_var(para.left,true);
+
                   { create the parameter list: the temp ... }
                   temp := ctempcreatenode.create(readfunctype,readfunctype.size,tt_persistent,false);
                   addstatement(Tstatementnode(newstatement),temp);

+ 34 - 0
tests/webtbf/tw8777k.pp

@@ -0,0 +1,34 @@
+{ %fail }
+program BugTest;
+
+{$mode objfpc}
+
+type
+  TTest = class
+  private
+    FTest: Byte;
+    procedure SetTest(const Value: Byte);
+  public
+    property Test: Byte read FTest write SetTest;
+  end;
+
+procedure p(var i : byte);
+  begin
+  end;
+
+{ TTest }
+
+procedure TTest.SetTest(const Value: Byte);
+begin
+  Writeln('SetTest called!');
+  FTest := Value;
+end;
+
+var
+  Test: TTest;
+
+begin
+  Test := TTest.Create;
+  Test.Test := 2;
+  ReadLn(Test.Test);
+end.