From 4bec57702f93cd54d61f68b1f8078ce4a4d985fc Mon Sep 17 00:00:00 2001 From: florian Date: Fri, 29 Jan 2021 21:31:59 +0000 Subject: [PATCH] * handle generic with ord call of sub-range and enumeration data excluding 0 correctly, resolves #38412 git-svn-id: trunk@48452 - --- .gitattributes | 1 + compiler/ncon.pas | 2 +- tests/webtbs/tw38412.pp | 10 ++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 tests/webtbs/tw38412.pp diff --git a/.gitattributes b/.gitattributes index 3973a35c2e..5755696dd0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18649,6 +18649,7 @@ tests/webtbs/tw38385.pp svneol=native#text/pascal tests/webtbs/tw38390.pp svneol=native#text/pascal tests/webtbs/tw3840.pp svneol=native#text/plain tests/webtbs/tw3841.pp svneol=native#text/plain +tests/webtbs/tw38412.pp svneol=native#text/pascal tests/webtbs/tw38413.pp svneol=native#text/pascal tests/webtbs/tw3863.pp svneol=native#text/plain tests/webtbs/tw3864.pp svneol=native#text/plain diff --git a/compiler/ncon.pas b/compiler/ncon.pas index dabb8fac44..048624d664 100644 --- a/compiler/ncon.pas +++ b/compiler/ncon.pas @@ -655,7 +655,7 @@ implementation resultdef:=typedef; { only do range checking when explicitly asked for it and if the type can be range checked, see tests/tbs/tb0539.pp } - if (resultdef.typ in [orddef,enumdef]) then + if (resultdef.typ in [orddef,enumdef]) and not(nf_generic_para in flags) then adaptrange(resultdef,value,nf_internal in flags,not rangecheck,rangecheck) end; diff --git a/tests/webtbs/tw38412.pp b/tests/webtbs/tw38412.pp new file mode 100644 index 0000000000..dcfe911a99 --- /dev/null +++ b/tests/webtbs/tw38412.pp @@ -0,0 +1,10 @@ +{ %norun } +type + measure = (short := 1, long := 2); + generic bar = object + public + const + myMeasure = ord(x); + end; +begin +end.