mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-07 07:39:31 +01:00
* forbid access to properties in class methods
* readability fix git-svn-id: trunk@11838 -
This commit is contained in:
parent
c79e23c5eb
commit
57f3e2f40a
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -6566,6 +6566,7 @@ tests/tbf/tb0209.pp svneol=native#text/plain
|
|||||||
tests/tbf/tb0210.pp svneol=native#text/plain
|
tests/tbf/tb0210.pp svneol=native#text/plain
|
||||||
tests/tbf/tb0211.pp svneol=native#text/plain
|
tests/tbf/tb0211.pp svneol=native#text/plain
|
||||||
tests/tbf/tb0212.pp svneol=native#text/plain
|
tests/tbf/tb0212.pp svneol=native#text/plain
|
||||||
|
tests/tbf/tb0213.pp svneol=native#text/plain
|
||||||
tests/tbf/ub0115.pp svneol=native#text/plain
|
tests/tbf/ub0115.pp svneol=native#text/plain
|
||||||
tests/tbf/ub0149.pp svneol=native#text/plain
|
tests/tbf/ub0149.pp svneol=native#text/plain
|
||||||
tests/tbf/ub0158a.pp svneol=native#text/plain
|
tests/tbf/ub0158a.pp svneol=native#text/plain
|
||||||
|
|||||||
@ -1568,6 +1568,8 @@ implementation
|
|||||||
{ property of a class/object? }
|
{ property of a class/object? }
|
||||||
if is_member_read(srsym,srsymtable,p1,hdef) then
|
if is_member_read(srsym,srsymtable,p1,hdef) then
|
||||||
begin
|
begin
|
||||||
|
if (srsymtable.symtabletype=ObjectSymtable) then
|
||||||
|
p1:=load_self_node;
|
||||||
{ not srsymtable.symtabletype since that can be }
|
{ not srsymtable.symtabletype since that can be }
|
||||||
{ withsymtable as well }
|
{ withsymtable as well }
|
||||||
if (srsym.owner.symtabletype=ObjectSymtable) then
|
if (srsym.owner.symtabletype=ObjectSymtable) then
|
||||||
@ -2232,9 +2234,8 @@ implementation
|
|||||||
check_hints(srsym,srsym.symoptions);
|
check_hints(srsym,srsym.symoptions);
|
||||||
{ load the procdef from the inherited class and
|
{ load the procdef from the inherited class and
|
||||||
not from self }
|
not from self }
|
||||||
if srsym.typ in [procsym,propertysym] then
|
case srsym.typ of
|
||||||
begin
|
procsym:
|
||||||
if (srsym.typ = procsym) then
|
|
||||||
begin
|
begin
|
||||||
hdef:=hclassdef;
|
hdef:=hclassdef;
|
||||||
if (po_classmethod in current_procinfo.procdef.procoptions) or
|
if (po_classmethod in current_procinfo.procdef.procoptions) or
|
||||||
@ -2242,12 +2243,14 @@ implementation
|
|||||||
hdef:=tclassrefdef.create(hdef);
|
hdef:=tclassrefdef.create(hdef);
|
||||||
p1:=ctypenode.create(hdef);
|
p1:=ctypenode.create(hdef);
|
||||||
end;
|
end;
|
||||||
end
|
propertysym:
|
||||||
|
;
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
Message(parser_e_methode_id_expected);
|
Message(parser_e_methode_id_expected);
|
||||||
p1:=cerrornode.create;
|
p1:=cerrornode.create;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
do_member_read(hclassdef,getaddr,srsym,p1,again,[cnf_inherited,cnf_anon_inherited]);
|
do_member_read(hclassdef,getaddr,srsym,p1,again,[cnf_inherited,cnf_anon_inherited]);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|||||||
16
tests/tbf/tb0213.pp
Normal file
16
tests/tbf/tb0213.pp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{ %fail }
|
||||||
|
{$mode objfpc}
|
||||||
|
type
|
||||||
|
tc1 = class
|
||||||
|
fp : longint;
|
||||||
|
class procedure p;
|
||||||
|
property prop : longint read fp;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure tc1.p;
|
||||||
|
begin
|
||||||
|
writeln(prop);
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
end.
|
||||||
Loading…
Reference in New Issue
Block a user