mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-09 19:08:15 +02:00
* handle explicit typecasts of procdefs to procvardefs always via
proc_to_procdef, because a methodpointer may have to be discarded git-svn-id: trunk@23929 -
This commit is contained in:
parent
5152c86932
commit
0ad9f345dd
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -9837,6 +9837,7 @@ tests/tbs/tb0591.pp svneol=native#text/pascal
|
||||
tests/tbs/tb0592.pp svneol=native#text/plain
|
||||
tests/tbs/tb0593.pp svneol=native#text/pascal
|
||||
tests/tbs/tb0594.pp svneol=native#text/plain
|
||||
tests/tbs/tb0595.pp svneol=native#text/plain
|
||||
tests/tbs/tb205.pp svneol=native#text/plain
|
||||
tests/tbs/tbs0594.pp svneol=native#text/pascal
|
||||
tests/tbs/ub0060.pp svneol=native#text/plain
|
||||
|
@ -2281,8 +2281,13 @@ implementation
|
||||
{ Handle explicit type conversions }
|
||||
if nf_explicit in flags then
|
||||
begin
|
||||
{ do common tc_equal cast }
|
||||
convtype:=tc_equal;
|
||||
{ do common tc_equal cast, except when dealing with proc -> procvar
|
||||
(may have to get rid of method pointer) }
|
||||
if (left.resultdef.typ<>procdef) or
|
||||
(resultdef.typ<>procvardef) then
|
||||
convtype:=tc_equal
|
||||
else
|
||||
convtype:=tc_proc_2_procvar;
|
||||
|
||||
{ ordinal constants can be resized to 1,2,4,8 bytes }
|
||||
if (left.nodetype=ordconstn) then
|
||||
|
25
tests/tbs/tb0595.pp
Normal file
25
tests/tbs/tb0595.pp
Normal file
@ -0,0 +1,25 @@
|
||||
{$mode delphi}{$h+}
|
||||
|
||||
type
|
||||
tc = class
|
||||
class procedure test; static;
|
||||
end;
|
||||
|
||||
tp = procedure;
|
||||
|
||||
var
|
||||
global: longint;
|
||||
|
||||
class procedure tc.test;
|
||||
begin
|
||||
global:=1;
|
||||
end;
|
||||
|
||||
var
|
||||
p: tp;
|
||||
begin
|
||||
p:=tp(tc.test);
|
||||
p();
|
||||
if global<>1 then
|
||||
halt(1);
|
||||
end.
|
Loading…
Reference in New Issue
Block a user