mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 06:29:32 +02:00
* don't crash when trying to access the call_self_node in case it doesn't
exit, but instead give an error (bug introduced in r30950, mantis #28338) git-svn-id: trunk@31150 -
This commit is contained in:
parent
b21610050f
commit
7866bae173
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -13180,6 +13180,7 @@ tests/webtbf/tw2751.pp svneol=native#text/plain
|
||||
tests/webtbf/tw2752.pp svneol=native#text/plain
|
||||
tests/webtbf/tw2787.pp svneol=native#text/plain
|
||||
tests/webtbf/tw2795.pp svneol=native#text/plain
|
||||
tests/webtbf/tw28338.pp svneol=native#text/plain
|
||||
tests/webtbf/tw2853.pp svneol=native#text/plain
|
||||
tests/webtbf/tw2853a.pp svneol=native#text/plain
|
||||
tests/webtbf/tw2853b.pp svneol=native#text/plain
|
||||
|
@ -84,6 +84,7 @@ interface
|
||||
procedure register_created_object_types;
|
||||
function get_expect_loc: tcgloc;
|
||||
protected
|
||||
function safe_call_self_node: tnode;
|
||||
procedure gen_vmt_entry_load; virtual;
|
||||
procedure gen_syscall_para(para: tcallparanode); virtual;
|
||||
procedure objc_convert_to_message_send;virtual;
|
||||
@ -2102,7 +2103,7 @@ implementation
|
||||
{ inherited }
|
||||
else if (cnf_inherited in callnodeflags) then
|
||||
begin
|
||||
selftree:=call_self_node.getcopy;
|
||||
selftree:=safe_call_self_node.getcopy;
|
||||
{ we can call an inherited class static/method from a regular method
|
||||
-> self node must change from instance pointer to vmt pointer)
|
||||
}
|
||||
@ -2158,7 +2159,7 @@ implementation
|
||||
end;
|
||||
end
|
||||
else
|
||||
selftree:=call_self_node.getcopy
|
||||
selftree:=safe_call_self_node.getcopy
|
||||
else
|
||||
selftree:=methodpointer.getcopy;
|
||||
end;
|
||||
@ -2195,7 +2196,7 @@ implementation
|
||||
else
|
||||
begin
|
||||
if methodpointer.nodetype=typen then
|
||||
selftree:=call_self_node.getcopy
|
||||
selftree:=safe_call_self_node.getcopy
|
||||
else
|
||||
selftree:=methodpointer.getcopy;
|
||||
end;
|
||||
@ -2333,6 +2334,17 @@ implementation
|
||||
end;
|
||||
|
||||
|
||||
function tcallnode.safe_call_self_node: tnode;
|
||||
begin
|
||||
if not assigned(call_self_node) then
|
||||
begin
|
||||
CGMessage(parser_e_illegal_expression);
|
||||
call_self_node:=cerrornode.create;
|
||||
end;
|
||||
result:=call_self_node;
|
||||
end;
|
||||
|
||||
|
||||
procedure tcallnode.gen_vmt_entry_load;
|
||||
var
|
||||
vmt_def: trecorddef;
|
||||
@ -2468,7 +2480,7 @@ implementation
|
||||
temp:=ctempcreatenode.create(objcsupertype,objcsupertype.size,tt_persistent,false);
|
||||
addstatement(statements,temp);
|
||||
{ initialize objc_super record }
|
||||
selftree:=call_self_node.getcopy;
|
||||
selftree:=safe_call_self_node.getcopy;
|
||||
|
||||
{ we can call an inherited class static/method from a regular method
|
||||
-> self node must change from instance pointer to vmt pointer)
|
||||
|
17
tests/webtbf/tw28338.pp
Normal file
17
tests/webtbf/tw28338.pp
Normal file
@ -0,0 +1,17 @@
|
||||
{ %fail }
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
program Project1;
|
||||
type
|
||||
tmyobj=object
|
||||
a:integer;
|
||||
function getsize:integer;
|
||||
end;
|
||||
function tmyobj.getsize:integer;
|
||||
begin
|
||||
result:=sizeof(self);
|
||||
end;
|
||||
begin
|
||||
writeln(tmyobj.getsize);
|
||||
end.
|
Loading…
Reference in New Issue
Block a user