* allow exlicit type conversions from class/interface to enums in Delphi

mode (mantis #11859)
  * cleaned up some superfluous "eq=te_incompatible" checks (probably from
    copy/pasting conditions from elsewhere)

git-svn-id: trunk@13050 -
This commit is contained in:
Jonas Maebe 2009-04-26 20:41:24 +00:00
parent 25c5d2658c
commit 5b08047d1c
3 changed files with 35 additions and 6 deletions

1
.gitattributes vendored
View File

@ -8746,6 +8746,7 @@ tests/webtbs/tw11846b.pp svneol=native#text/plain
tests/webtbs/tw11848.pp svneol=native#text/plain
tests/webtbs/tw11849.pp svneol=native#text/plain
tests/webtbs/tw11852.pp svneol=native#text/plain
tests/webtbs/tw11859.pp svneol=native#text/plain
tests/webtbs/tw11861.pp svneol=native#text/plain
tests/webtbs/tw11862.pp svneol=native#text/plain
tests/webtbs/tw11896.pp svneol=native#text/plain

View File

@ -614,8 +614,18 @@ implementation
begin
{ ugly, but delphi allows it }
if (cdo_explicit in cdoptions) and
(m_delphi in current_settings.modeswitches) and
(eq=te_incompatible) then
(m_delphi in current_settings.modeswitches) then
begin
doconv:=tc_int_2_int;
eq:=te_convert_l1;
end;
end;
objectdef:
begin
{ ugly, but delphi allows it }
if (m_delphi in current_settings.modeswitches) and
is_class_or_interface_or_dispinterface(def_from) and
(cdo_explicit in cdoptions) then
begin
doconv:=tc_int_2_int;
eq:=te_convert_l1;
@ -962,8 +972,7 @@ implementation
{ allow explicit typecasts from enums to pointer.
Support for delphi compatibility
}
if (eq=te_incompatible) and
(((cdo_explicit in cdoptions) and
if (((cdo_explicit in cdoptions) and
(m_delphi in current_settings.modeswitches)
) or
(cdo_internal in cdoptions)
@ -1263,8 +1272,7 @@ implementation
eq:=te_convert_l2;
end
{ ugly, but delphi allows it }
else if (eq=te_incompatible) and
(def_from.typ in [orddef,enumdef]) and
else if (def_from.typ in [orddef,enumdef]) and
(m_delphi in current_settings.modeswitches) and
(cdo_explicit in cdoptions) then
begin

20
tests/webtbs/tw11859.pp Normal file
View File

@ -0,0 +1,20 @@
{$ifdef fpc}
{$mode delphi}
{$endif}
{$z4}
type
tenum = (ea,eb,ec);
var
c1, c2: tobject;
e: tenum;
begin
{$r-}
c1:=tobject(pointer(12345));
e:=tenum(c1);
c2:=tobject(e);
if (c1<>c2) then
halt(1);
end.