From d4d70d3865980fdd94e14bb69f2f06c74a6cd2be Mon Sep 17 00:00:00 2001 From: yury Date: Sat, 26 Mar 2016 17:48:50 +0000 Subject: [PATCH] * Evaluate currency constant expressions when the currency type is 64-bit integer. Issue #28749. git-svn-id: trunk@33334 - --- .gitattributes | 1 + compiler/nadd.pas | 4 ++++ tests/webtbs/tw28749.pp | 14 ++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 tests/webtbs/tw28749.pp diff --git a/.gitattributes b/.gitattributes index fc311b2657..e28869d650 100644 --- a/.gitattributes +++ b/.gitattributes @@ -14924,6 +14924,7 @@ tests/webtbs/tw28718b.pp svneol=native#text/plain tests/webtbs/tw28718c.pp svneol=native#text/plain tests/webtbs/tw28718d.pp svneol=native#text/plain tests/webtbs/tw28748.pp svneol=native#text/plain +tests/webtbs/tw28749.pp svneol=native#text/plain tests/webtbs/tw2876.pp svneol=native#text/plain tests/webtbs/tw28766.pp svneol=native#text/pascal tests/webtbs/tw28801.pp svneol=native#text/plain diff --git a/compiler/nadd.pas b/compiler/nadd.pas index cd14a42ef0..ca09766b15 100644 --- a/compiler/nadd.pas +++ b/compiler/nadd.pas @@ -437,6 +437,10 @@ implementation (lt in [pointerconstn,niln]) and (rt in [pointerconstn,niln]) and (nodetype in [ltn,lten,gtn,gten,equaln,unequaln,subn]) + ) or + ( + (lt = ordconstn) and (ld.typ = orddef) and is_currency(ld) and + (rt = ordconstn) and (rd.typ = orddef) and is_currency(rd) ) then begin t:=nil; diff --git a/tests/webtbs/tw28749.pp b/tests/webtbs/tw28749.pp new file mode 100644 index 0000000000..a241b5a790 --- /dev/null +++ b/tests/webtbs/tw28749.pp @@ -0,0 +1,14 @@ +uses + SysUtils; +var + s: string; + c: currency; +begin + c:=Currency(0.12) + Currency(0.14); + s:=CurrToStr(c); + s:=StringReplace(s, FormatSettings.DecimalSeparator, '.', []); + writeln('s=', s); + if s <> '0.26' then + Halt(1); + writeln('OK'); +end.