Browse Source

* handle subrange enumeration types in GetEnumValue correctly, resolves #15467

git-svn-id: trunk@14544 -
florian 16 years ago
parent
commit
4ddebcbf1c
3 changed files with 16 additions and 2 deletions
  1. 1 0
      .gitattributes
  2. 1 2
      rtl/objpas/typinfo.pp
  3. 14 0
      tests/webtbs/tw15467.pp

+ 1 - 0
.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

+ 1 - 2
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;

+ 14 - 0
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.