From 76a3d55199f32101503337fa11087d78543c7f57 Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 1 Jul 2007 14:43:46 +0000 Subject: [PATCH] * allow enum => pointer type casts in delphi mode, resolves #8465 git-svn-id: trunk@7905 - --- .gitattributes | 1 + compiler/defcmp.pas | 2 -- tests/webtbf/tw8465a.pp | 18 ++++++++++++++++++ tests/webtbs/tw8465.pp | 4 +++- 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 tests/webtbf/tw8465a.pp diff --git a/.gitattributes b/.gitattributes index 949632d2ce..41b6d924a9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7381,6 +7381,7 @@ tests/webtbf/tw8150g.pp svneol=native#text/plain tests/webtbf/tw8264a.pp svneol=native#text/plain tests/webtbf/tw8398.pp svneol=native#text/plain tests/webtbf/tw8451.pp svneol=native#text/plain +tests/webtbf/tw8465a.pp svneol=native#text/plain tests/webtbf/tw8528.pp svneol=native#text/plain tests/webtbf/tw8583.pp svneol=native#text/plain tests/webtbf/tw8588.pp svneol=native#text/plain diff --git a/compiler/defcmp.pas b/compiler/defcmp.pas index 09cf9bb8af..aac2ed744e 100644 --- a/compiler/defcmp.pas +++ b/compiler/defcmp.pas @@ -933,7 +933,6 @@ implementation eq:=te_convert_l1; end; end; -{ enumdef : begin { allow explicit typecasts from enums to pointer. @@ -950,7 +949,6 @@ implementation eq:=te_convert_l1; end; end; -} arraydef : begin { string constant (which can be part of array constructor) diff --git a/tests/webtbf/tw8465a.pp b/tests/webtbf/tw8465a.pp new file mode 100644 index 0000000000..f83ab3cefe --- /dev/null +++ b/tests/webtbf/tw8465a.pp @@ -0,0 +1,18 @@ +{ %fail } +program EnumPtrConvTest; + +{$APPTYPE CONSOLE} + +{$packenum 1} +type + TEnum = (a, b); + +var + e: TEnum; + p: Pointer; + +begin + e := b; + p := Pointer(e); + WriteLn(Integer(p)); // produces "1" in Delphi +end. diff --git a/tests/webtbs/tw8465.pp b/tests/webtbs/tw8465.pp index 196d603e6f..971e70970c 100644 --- a/tests/webtbs/tw8465.pp +++ b/tests/webtbs/tw8465.pp @@ -5,6 +5,7 @@ program EnumPtrConvTest; {$IFDEF FPC} {$MODE DELPHI} {$ENDIF} +{$packenum 1} type TEnum = (a, b); @@ -16,5 +17,6 @@ var begin e := b; p := Pointer(e); - WriteLn(Integer(p)); // produces "1" in Delphi + if Integer(p)<>1 then + halt(1); // produces "1" in Delphi end.