mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-27 22:13:01 +02:00
* allow modifying lvalues obtained by dereferencing read-only properties,
both via regular pointers and via classes (mantis 9498) git-svn-id: trunk@8755 -
This commit is contained in:
parent
b5a1a6c6b4
commit
0ebc1e920a
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -7495,6 +7495,7 @@ tests/webtbf/tw9522d.pp svneol=native#text/plain
|
|||||||
tests/webtbf/tw9522e.pp svneol=native#text/plain
|
tests/webtbf/tw9522e.pp svneol=native#text/plain
|
||||||
tests/webtbf/tw9579a.pp svneol=native#text/plain
|
tests/webtbf/tw9579a.pp svneol=native#text/plain
|
||||||
tests/webtbf/tw9579b.pp svneol=native#text/plain
|
tests/webtbf/tw9579b.pp svneol=native#text/plain
|
||||||
|
tests/webtbf/tw9894b.pp svneol=native#text/plain
|
||||||
tests/webtbf/uw0744.pp svneol=native#text/plain
|
tests/webtbf/uw0744.pp svneol=native#text/plain
|
||||||
tests/webtbf/uw0840a.pp svneol=native#text/plain
|
tests/webtbf/uw0840a.pp svneol=native#text/plain
|
||||||
tests/webtbf/uw0840b.pp svneol=native#text/plain
|
tests/webtbf/uw0840b.pp svneol=native#text/plain
|
||||||
@ -8474,6 +8475,8 @@ tests/webtbs/tw9695.pp svneol=native#text/plain
|
|||||||
tests/webtbs/tw9704.pp svneol=native#text/plain
|
tests/webtbs/tw9704.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw9766.pp svneol=native#text/plain
|
tests/webtbs/tw9766.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw9827.pp svneol=native#text/plain
|
tests/webtbs/tw9827.pp svneol=native#text/plain
|
||||||
|
tests/webtbs/tw9894.pp svneol=native#text/plain
|
||||||
|
tests/webtbs/tw9894a.pp svneol=native#text/plain
|
||||||
tests/webtbs/ub1873.pp svneol=native#text/plain
|
tests/webtbs/ub1873.pp svneol=native#text/plain
|
||||||
tests/webtbs/ub1883.pp svneol=native#text/plain
|
tests/webtbs/ub1883.pp svneol=native#text/plain
|
||||||
tests/webtbs/uw0555.pp svneol=native#text/plain
|
tests/webtbs/uw0555.pp svneol=native#text/plain
|
||||||
|
@ -987,10 +987,14 @@ implementation
|
|||||||
temps like calls that return a structure and we
|
temps like calls that return a structure and we
|
||||||
are assigning to a member }
|
are assigning to a member }
|
||||||
if (valid_const in opts) or
|
if (valid_const in opts) or
|
||||||
not(
|
{ if we got a deref, we won't modify the property itself }
|
||||||
(gotsubscript and gotrecord) or
|
(gotderef) or
|
||||||
(gotstring and gotvec)
|
{ same when we got a class and subscript (= deref) }
|
||||||
) then
|
(gotclass and gotsubscript) or
|
||||||
|
(
|
||||||
|
not(gotsubscript and gotrecord) and
|
||||||
|
not(gotstring and gotvec)
|
||||||
|
) then
|
||||||
result:=true
|
result:=true
|
||||||
else
|
else
|
||||||
if report_errors then
|
if report_errors then
|
||||||
|
37
tests/webtbf/tw9894b.pp
Normal file
37
tests/webtbf/tw9894b.pp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{ %fail }
|
||||||
|
|
||||||
|
{$mode delphi}
|
||||||
|
|
||||||
|
unit tw9894b;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
Type
|
||||||
|
TMyInteger = Class
|
||||||
|
Value : Integer;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TMyRec2 = record
|
||||||
|
MyInteger : TMyInteger;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TMyRec = record
|
||||||
|
MyRec2 : TMyRec2;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TMyClass = Class
|
||||||
|
FMyRec : TMyRec;
|
||||||
|
Private
|
||||||
|
Procedure DoSomething;
|
||||||
|
Property MyRec : TMyRec Read FMyRec;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Implementation
|
||||||
|
|
||||||
|
Procedure TMyClass.DoSomething;
|
||||||
|
|
||||||
|
begin
|
||||||
|
MyRec.MyRec2.MyInteger:=TMyInteger(nil);
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
32
tests/webtbs/tw9894.pp
Normal file
32
tests/webtbs/tw9894.pp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
{$mode delphi}
|
||||||
|
|
||||||
|
unit tw9894;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
Type
|
||||||
|
PMyInteger = ^TMyInteger;
|
||||||
|
TMyInteger = record
|
||||||
|
Value : Integer;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TMyRec = record
|
||||||
|
MyInteger : PMyInteger;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TMyClass = Class
|
||||||
|
FMyRec : TMyRec;
|
||||||
|
Private
|
||||||
|
Procedure DoSomething;
|
||||||
|
Property MyRec : TMyRec Read FMyRec;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Implementation
|
||||||
|
|
||||||
|
Procedure TMyClass.DoSomething;
|
||||||
|
|
||||||
|
begin
|
||||||
|
MyRec.MyInteger^.Value:=3;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
31
tests/webtbs/tw9894a.pp
Normal file
31
tests/webtbs/tw9894a.pp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{$mode delphi}
|
||||||
|
|
||||||
|
unit tw9894a;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
Type
|
||||||
|
TMyInteger = Class
|
||||||
|
Value : Integer;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TMyRec = record
|
||||||
|
MyInteger : TMyInteger;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TMyClass = Class
|
||||||
|
FMyRec : TMyRec;
|
||||||
|
Private
|
||||||
|
Procedure DoSomething;
|
||||||
|
Property MyRec : TMyRec Read FMyRec;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Implementation
|
||||||
|
|
||||||
|
Procedure TMyClass.DoSomething;
|
||||||
|
|
||||||
|
begin
|
||||||
|
MyRec.MyInteger.Value:=3;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user