From b7a716cd813c4416ae9bd01e112aaeeed0c48447 Mon Sep 17 00:00:00 2001 From: svenbarth Date: Fri, 26 Apr 2019 08:13:11 +0000 Subject: [PATCH] * correct return a pointer to the list so that List^[x] works as it did before 3.2 + added test git-svn-id: trunk@41938 - --- .gitattributes | 1 + rtl/objpas/fgl.pp | 6 +++--- tests/tbs/tb0657.pp | 29 +++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 tests/tbs/tb0657.pp diff --git a/.gitattributes b/.gitattributes index d063f9dbf1..50bd0806d0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -11830,6 +11830,7 @@ tests/tbs/tb0653.pp svneol=native#text/plain tests/tbs/tb0654.pp svneol=native#text/plain tests/tbs/tb0655.pp svneol=native#text/pascal tests/tbs/tb0656.pp svneol=native#text/pascal +tests/tbs/tb0657.pp svneol=native#text/pascal tests/tbs/tb205.pp svneol=native#text/plain tests/tbs/tb610.pp svneol=native#text/pascal tests/tbs/tb613.pp svneol=native#text/plain diff --git a/rtl/objpas/fgl.pp b/rtl/objpas/fgl.pp index fa70673557..91da1c362b 100644 --- a/rtl/objpas/fgl.pp +++ b/rtl/objpas/fgl.pp @@ -900,7 +900,7 @@ end; function TFPGList.GetList: PTypeList; begin - Result := PTypeList(FList); + Result := PTypeList(@FList); end; function TFPGList.ItemPtrCompare(Item1, Item2: Pointer): Integer; @@ -1035,7 +1035,7 @@ end; function TFPGObjectList.GetList: PTypeList; begin - Result := PTypeList(FList); + Result := PTypeList(@FList); end; function TFPGObjectList.ItemPtrCompare(Item1, Item2: Pointer): Integer; @@ -1165,7 +1165,7 @@ end; function TFPGInterfacedObjectList.GetList: PTypeList; begin - Result := PTypeList(FList); + Result := PTypeList(@FList); end; function TFPGInterfacedObjectList.ItemPtrCompare(Item1, Item2: Pointer): Integer; diff --git a/tests/tbs/tb0657.pp b/tests/tbs/tb0657.pp new file mode 100644 index 0000000000..e890ed9d0c --- /dev/null +++ b/tests/tbs/tb0657.pp @@ -0,0 +1,29 @@ +program tb0657; + +{$mode objfpc} + +uses + fgl; + +type + TIntList = specialize TFPGList; + +const + c = 3; + +var + l: TIntList; + i: LongInt; +begin + l := TIntList.Create; + try + for i := 0 to c do + l.Add(i); + + for i := 0 to l.Count - 1 do + if l.List^[i] <> i then + Halt(i + 1); + finally + l.Free; + end; +end.