From 4ddebcbf1c5a5dfe6395a4191ba0f9e243746518 Mon Sep 17 00:00:00 2001 From: florian Date: Tue, 5 Jan 2010 16:10:13 +0000 Subject: [PATCH] * handle subrange enumeration types in GetEnumValue correctly, resolves #15467 git-svn-id: trunk@14544 - --- .gitattributes | 1 + rtl/objpas/typinfo.pp | 3 +-- tests/webtbs/tw15467.pp | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 tests/webtbs/tw15467.pp diff --git a/.gitattributes b/.gitattributes index 6d197e644a..fbc3fb2864 100644 --- a/.gitattributes +++ b/.gitattributes @@ -10177,6 +10177,7 @@ tests/webtbs/tw15391.pp svneol=native#text/plain tests/webtbs/tw15415.pp svneol=native#text/plain tests/webtbs/tw15446.pp svneol=native#text/plain tests/webtbs/tw15453a.pp svneol=native#text/plain +tests/webtbs/tw15467.pp svneol=native#text/pascal tests/webtbs/tw1567.pp svneol=native#text/plain tests/webtbs/tw1573.pp svneol=native#text/plain tests/webtbs/tw1592.pp svneol=native#text/plain diff --git a/rtl/objpas/typinfo.pp b/rtl/objpas/typinfo.pp index 5bdb00ca88..d88594a201 100644 --- a/rtl/objpas/typinfo.pp +++ b/rtl/objpas/typinfo.pp @@ -421,12 +421,11 @@ begin end else begin - PS:=@PT^.NameList; While (Result=-1) and (PByte(PS)^<>0) do begin If ShortCompareText(PS^, sName) = 0 then - Result:=Count; + Result:=Count+PT^.MinValue; PS:=PShortString(pointer(PS)+PByte(PS)^+1); Inc(Count); end; diff --git a/tests/webtbs/tw15467.pp b/tests/webtbs/tw15467.pp new file mode 100644 index 0000000000..4b943e56a3 --- /dev/null +++ b/tests/webtbs/tw15467.pp @@ -0,0 +1,14 @@ +program test; + +uses typinfo; + +Type + E1 = (en1,en2,en3,en4,en5); + E2 = en3..en5; +begin + if (GetEnumValue(TypeInfo(E1),'en5') <> 4) then + halt(1); + if (GetEnumValue(TypeInfo(E2),'en5') <> 4) then + halt(1); + writeln('ok'); +end.