mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 18:49:27 +02:00
* convert function like used new into a appropriate nodes only in pass_1 so proper error checking can be carried out, resolves #24495
git-svn-id: trunk@24667 -
This commit is contained in:
parent
f2ff50f80e
commit
0968d095ed
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -12333,6 +12333,7 @@ tests/webtbf/tw2414.pp svneol=native#text/plain
|
|||||||
tests/webtbf/tw24184.pp svneol=native#text/plain
|
tests/webtbf/tw24184.pp svneol=native#text/plain
|
||||||
tests/webtbf/tw24428.pp svneol=native#text/plain
|
tests/webtbf/tw24428.pp svneol=native#text/plain
|
||||||
tests/webtbf/tw24428a.pp svneol=native#text/plain
|
tests/webtbf/tw24428a.pp svneol=native#text/plain
|
||||||
|
tests/webtbf/tw24495.pp svneol=native#text/pascal
|
||||||
tests/webtbf/tw2478.pp svneol=native#text/plain
|
tests/webtbf/tw2478.pp svneol=native#text/plain
|
||||||
tests/webtbf/tw2562.pp svneol=native#text/plain
|
tests/webtbf/tw2562.pp svneol=native#text/plain
|
||||||
tests/webtbf/tw2657.pp svneol=native#text/plain
|
tests/webtbf/tw2657.pp svneol=native#text/plain
|
||||||
|
@ -2988,6 +2988,9 @@ implementation
|
|||||||
tcallparanode(tcallparanode(left).right).left.resultdef.typename);
|
tcallparanode(tcallparanode(left).right).left.resultdef.typename);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
in_new_x:
|
||||||
|
resultdef:=left.resultdef;
|
||||||
|
|
||||||
in_low_x,
|
in_low_x,
|
||||||
in_high_x:
|
in_high_x:
|
||||||
begin
|
begin
|
||||||
@ -3931,12 +3934,48 @@ implementation
|
|||||||
left:=nil;
|
left:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function tinlinenode.first_new: tnode;
|
function tinlinenode.first_new: tnode;
|
||||||
|
var
|
||||||
|
newstatement : tstatementnode;
|
||||||
|
newblock : tblocknode;
|
||||||
|
temp : ttempcreatenode;
|
||||||
|
para : tcallparanode;
|
||||||
begin
|
begin
|
||||||
internalerror(2011012201);
|
{ create statements with call to getmem+initialize }
|
||||||
result:=nil;
|
newblock:=internalstatements(newstatement);
|
||||||
|
|
||||||
|
{ create temp for result }
|
||||||
|
temp := ctempcreatenode.create(left.resultdef,left.resultdef.size,tt_persistent,true);
|
||||||
|
addstatement(newstatement,temp);
|
||||||
|
|
||||||
|
{ create call to fpc_getmem }
|
||||||
|
para := ccallparanode.create(cordconstnode.create
|
||||||
|
(tpointerdef(left.resultdef).pointeddef.size,s32inttype,true),nil);
|
||||||
|
addstatement(newstatement,cassignmentnode.create(
|
||||||
|
ctemprefnode.create(temp),
|
||||||
|
ccallnode.createintern('fpc_getmem',para)));
|
||||||
|
|
||||||
|
{ create call to fpc_initialize }
|
||||||
|
if is_managed_type(tpointerdef(left.resultdef).pointeddef) then
|
||||||
|
begin
|
||||||
|
para := ccallparanode.create(caddrnode.create_internal(crttinode.create
|
||||||
|
(tstoreddef(tpointerdef(left.resultdef).pointeddef),initrtti,rdt_normal)),
|
||||||
|
ccallparanode.create(ctemprefnode.create
|
||||||
|
(temp),nil));
|
||||||
|
addstatement(newstatement,ccallnode.createintern('fpc_initialize',para));
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ the last statement should return the value as
|
||||||
|
location and type, this is done be referencing the
|
||||||
|
temp and converting it first from a persistent temp to
|
||||||
|
normal temp }
|
||||||
|
addstatement(newstatement,ctempdeletenode.create_normal_temp(temp));
|
||||||
|
addstatement(newstatement,ctemprefnode.create(temp));
|
||||||
|
result:=newblock;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function tinlinenode.first_length: tnode;
|
function tinlinenode.first_length: tnode;
|
||||||
begin
|
begin
|
||||||
result:=nil;
|
result:=nil;
|
||||||
|
@ -447,39 +447,10 @@ implementation
|
|||||||
(oo_has_vmt in tobjectdef(tpointerdef(p1.resultdef).pointeddef).objectoptions) then
|
(oo_has_vmt in tobjectdef(tpointerdef(p1.resultdef).pointeddef).objectoptions) then
|
||||||
Message(parser_w_use_extended_syntax_for_objects);
|
Message(parser_w_use_extended_syntax_for_objects);
|
||||||
|
|
||||||
{ create statements with call to getmem+initialize }
|
if p1.nodetype=typen then
|
||||||
newblock:=internalstatements(newstatement);
|
ttypenode(p1).allowed:=true;
|
||||||
|
|
||||||
{ create temp for result }
|
p1:=cinlinenode.create(in_new_x,false,p1);
|
||||||
temp := ctempcreatenode.create(p1.resultdef,p1.resultdef.size,tt_persistent,true);
|
|
||||||
addstatement(newstatement,temp);
|
|
||||||
|
|
||||||
{ create call to fpc_getmem }
|
|
||||||
para := ccallparanode.create(cordconstnode.create
|
|
||||||
(tpointerdef(p1.resultdef).pointeddef.size,s32inttype,true),nil);
|
|
||||||
addstatement(newstatement,cassignmentnode.create(
|
|
||||||
ctemprefnode.create(temp),
|
|
||||||
ccallnode.createintern('fpc_getmem',para)));
|
|
||||||
|
|
||||||
{ create call to fpc_initialize }
|
|
||||||
if is_managed_type(tpointerdef(p1.resultdef).pointeddef) then
|
|
||||||
begin
|
|
||||||
para := ccallparanode.create(caddrnode.create_internal(crttinode.create
|
|
||||||
(tstoreddef(tpointerdef(p1.resultdef).pointeddef),initrtti,rdt_normal)),
|
|
||||||
ccallparanode.create(ctemprefnode.create
|
|
||||||
(temp),nil));
|
|
||||||
addstatement(newstatement,ccallnode.createintern('fpc_initialize',para));
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ the last statement should return the value as
|
|
||||||
location and type, this is done be referencing the
|
|
||||||
temp and converting it first from a persistent temp to
|
|
||||||
normal temp }
|
|
||||||
addstatement(newstatement,ctempdeletenode.create_normal_temp(temp));
|
|
||||||
addstatement(newstatement,ctemprefnode.create(temp));
|
|
||||||
|
|
||||||
p1.destroy;
|
|
||||||
p1:=newblock;
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
|
9
tests/webtbf/tw24495.pp
Normal file
9
tests/webtbf/tw24495.pp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{ %fail }
|
||||||
|
program Project1;
|
||||||
|
type
|
||||||
|
PFoo = ^Integer;
|
||||||
|
var
|
||||||
|
a: Pointer;
|
||||||
|
begin
|
||||||
|
a:= @New(PFoo);
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user