From aec18c2426a503c0c85e057bbc2f029d649fe3bf Mon Sep 17 00:00:00 2001 From: florian Date: Tue, 5 Jan 2021 22:39:16 +0000 Subject: [PATCH] * weight currency->float conversions the same regardless if the currency type is handled by the integer unit or the x87 fpu, resolves #38309 git-svn-id: trunk@48089 - --- .gitattributes | 1 + compiler/defcmp.pas | 6 ++--- tests/webtbs/tw38309.pp | 56 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 tests/webtbs/tw38309.pp diff --git a/.gitattributes b/.gitattributes index cd485efcde..b6ed4a29e7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18632,6 +18632,7 @@ tests/webtbs/tw3827.pp svneol=native#text/plain tests/webtbs/tw3829.pp svneol=native#text/plain tests/webtbs/tw38295.pp svneol=native#text/pascal tests/webtbs/tw38299.pp svneol=native#text/pascal +tests/webtbs/tw38309.pp svneol=native#text/pascal tests/webtbs/tw38310a.pp svneol=native#text/pascal tests/webtbs/tw38310b.pp svneol=native#text/pascal tests/webtbs/tw38310c.pp svneol=native#text/pascal diff --git a/compiler/defcmp.pas b/compiler/defcmp.pas index 1d18a1649b..867b09f141 100644 --- a/compiler/defcmp.pas +++ b/compiler/defcmp.pas @@ -843,11 +843,11 @@ implementation { and conversion to float is favoured) } doconv:=tc_int_2_real; if is_extended(def_to) then - eq:=te_convert_l2 + eq:=te_convert_l1 else if is_double(def_to) then - eq:=te_convert_l3 + eq:=te_convert_l2 else if is_single(def_to) then - eq:=te_convert_l4 + eq:=te_convert_l3 else eq:=te_convert_l2; end; diff --git a/tests/webtbs/tw38309.pp b/tests/webtbs/tw38309.pp new file mode 100644 index 0000000000..a33ef45053 --- /dev/null +++ b/tests/webtbs/tw38309.pp @@ -0,0 +1,56 @@ +program c; + +{$mode objfpc} + +uses + Math; + +type + generic TBase = class + private const + AConst = 1; + private + GenVarA: T; + GenVarB: T; + function Foo: Boolean; + end; + + function TBase.Foo: Boolean; + begin + //Fails with trunk win-64 if TCur type is defined (e.g. not commented out) (*) + Result := SameValue(AConst, GenVarB); + + //Fails with trunk win-64, EVEN if TCur definition is commented out + //Fails with 3.2.0 win-32, EVEN if TCur definition is commented out + //Fails with 3.2.0 win-64, EVEN if TCur definition is commented out, if it is defined it gives the errormesage twice for this line + Result := SameValue(GenVarA, GenVarB); + + //Fails with trunk win-64 if TCur type is defined (e.g. not commented out) + Result := SameValue(GenVarA, AConst); + end; + +type + TCur = specialize TBase; + +const + CurConst = 1; +var + CurVarA: Currency = 1; + CurVarB: Currency = 2; + +begin + //Fails with trunk win-64 + SameValue(CurConst, CurVarA); + + //Fails with 3.2.0 win-64 + SameValue(Currency(CurConst), CurVarA); + + //Fails with 3.2.0 win-64 + SameValue(CurVarA, CurVarB); + + //Fails with trunk win-64 + SameValue(CurVarA, CurConst); + + //Fails with 3.2.0 win-64 + SameValue(CurVarA, Currency(CurConst)); +end.