mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-25 00:29:25 +02:00
+ test conversion from class to differently sized enum and to differently
sized integer (succeed for Delphi, fail for objfpc) * fixed compiler so it only allows typecasting a class/interface to a differently sized integer in Delphi mode git-svn-id: trunk@13152 -
This commit is contained in:
parent
47c28c2db3
commit
3a8b29be91
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -6688,7 +6688,9 @@ tests/tbf/tb0207.pp svneol=native#text/plain
|
||||
tests/tbf/tb0208.pp svneol=native#text/plain
|
||||
tests/tbf/tb0209.pp svneol=native#text/plain
|
||||
tests/tbf/tb0210.pp svneol=native#text/plain
|
||||
tests/tbf/tb0210a.pp svneol=native#text/plain
|
||||
tests/tbf/tb0211.pp svneol=native#text/plain
|
||||
tests/tbf/tb0211a.pp svneol=native#text/plain
|
||||
tests/tbf/tb0212.pp svneol=native#text/plain
|
||||
tests/tbf/tb0213.pp svneol=native#text/plain
|
||||
tests/tbf/tb0214.pp svneol=native#text/plain
|
||||
|
@ -276,7 +276,9 @@ implementation
|
||||
end;
|
||||
objectdef:
|
||||
begin
|
||||
if is_class_or_interface_or_dispinterface(def_from) and (cdo_explicit in cdoptions) then
|
||||
if (m_delphi in current_settings.modeswitches) and
|
||||
is_class_or_interface_or_dispinterface(def_from) and
|
||||
(cdo_explicit in cdoptions) then
|
||||
begin
|
||||
eq:=te_convert_l1;
|
||||
if (fromtreetype=niln) then
|
||||
|
17
tests/tbf/tb0210a.pp
Normal file
17
tests/tbf/tb0210a.pp
Normal file
@ -0,0 +1,17 @@
|
||||
{ %fail }
|
||||
|
||||
// check whether enums can NOT be casted to object references; this
|
||||
// should NOT work in objfpc mode (see also tbs/tb0554.pp)
|
||||
{$mode objfpc}
|
||||
|
||||
{$packenum 2}
|
||||
type
|
||||
TEnum = (a, b, c);
|
||||
|
||||
var
|
||||
e : TEnum;
|
||||
o : TObject;
|
||||
|
||||
begin
|
||||
e := TEnum(o);
|
||||
end.
|
13
tests/tbf/tb0211a.pp
Normal file
13
tests/tbf/tb0211a.pp
Normal file
@ -0,0 +1,13 @@
|
||||
{ %fail }
|
||||
|
||||
// check whether integers can NOT be casted to object references; this
|
||||
// should NOT work in objfpc mode (see also tbs/tb0554.pp)
|
||||
{$mode objfpc}
|
||||
|
||||
var
|
||||
i : Word;
|
||||
o : TObject;
|
||||
|
||||
begin
|
||||
i := Word(o);
|
||||
end.
|
@ -1,16 +1,18 @@
|
||||
// check whether enums and integers can be casted to object references; this
|
||||
// should work in Delphi mode (is Delphi compatible)
|
||||
{$mode delphi}
|
||||
|
||||
{$packenum 2}
|
||||
type
|
||||
TEnum = (a, b, c);
|
||||
|
||||
var
|
||||
i : Integer;
|
||||
i : Word;
|
||||
e : TEnum;
|
||||
o : TObject;
|
||||
|
||||
begin
|
||||
o := TObject(e);
|
||||
o := TObject(i);
|
||||
i := Word(o);
|
||||
e := TEnum(o);
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user