Преглед на файлове

* 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 -

svenbarth преди 6 години
родител
ревизия
b7a716cd81
променени са 3 файла, в които са добавени 33 реда и са изтрити 3 реда
  1. 1 0
      .gitattributes
  2. 3 3
      rtl/objpas/fgl.pp
  3. 29 0
      tests/tbs/tb0657.pp

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

+ 3 - 3
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;

+ 29 - 0
tests/tbs/tb0657.pp

@@ -0,0 +1,29 @@
+program tb0657;
+
+{$mode objfpc}
+
+uses
+  fgl;
+
+type
+  TIntList = specialize TFPGList<LongInt>;
+
+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.