Przeglądaj źródła

+ test for mantis #16582 (already works with FPC 2.6.4)

git-svn-id: trunk@30909 -
Jonas Maebe 10 lat temu
rodzic
commit
00b68dfd9f
2 zmienionych plików z 76 dodań i 0 usunięć
  1. 1 0
      .gitattributes
  2. 75 0
      tests/webtbs/tw16582.pp

+ 1 - 0
.gitattributes

@@ -13854,6 +13854,7 @@ tests/webtbs/tw16366.pp svneol=native#text/plain
 tests/webtbs/tw16377.pp svneol=native#text/plain
 tests/webtbs/tw16402.pp svneol=native#text/plain
 tests/webtbs/tw1658.pp svneol=native#text/plain
+tests/webtbs/tw16582.pp svneol=native#text/plain
 tests/webtbs/tw16592.pp svneol=native#text/plain
 tests/webtbs/tw16622.pp svneol=native#text/pascal
 tests/webtbs/tw16668.pp svneol=native#text/plain

+ 75 - 0
tests/webtbs/tw16582.pp

@@ -0,0 +1,75 @@
+program Project1;
+
+{$mode objfpc}{$H+}
+{$inline on}
+
+uses
+  {$IFDEF UNIX}{$IFDEF UseCThreads}
+    cthreads,
+  {$ENDIF}{$ENDIF}
+  Classes, sysutils;
+
+type
+
+  { T1 }
+
+  generic T1<_T> = class
+    private
+      i:_T;
+      procedure SetF(v:_T);
+      function GetF:_T;
+  end;
+
+  TPointerList = specialize T1<Pointer>;
+
+  { TPointerList2 }
+
+  generic TPointerList2<_T2> = class(TPointerList)
+    public
+      procedure SetF(v:_T2);//inline; //when uncommented gives error - Illegal expression.
+      procedure WriteLn;
+  end;
+
+  TPointerListInt = specialize TPointerList2<PInteger>;
+  TPointerListDouble = specialize TPointerList2<PDouble>;
+
+  { T1 }
+
+procedure T1.SetF(v: _T);
+begin
+  i:=v;
+end;
+
+function T1.GetF: _T;
+begin
+  Result:=i;
+end;
+
+{ TPointerList2 }
+
+procedure TPointerList2.SetF(v: _T2); inline;
+begin
+  inherited SetF( Pointer(v) );
+end;
+
+procedure TPointerList2.WriteLn;
+var S:string;
+begin
+  S:=Format('%P', [i] );
+  System.WriteLn(S);
+end;
+
+var IntO:TPointerListInt;
+    DoubleO:TPointerListDouble;
+begin
+  IntO:=TPointerListInt.Create;
+  IntO.SetF( PInteger(nil) );
+  IntO.WriteLn;
+  IntO.Free;
+
+  DoubleO:=TPointerListDouble.Create;
+  DoubleO.SetF( PDouble(nil) );
+  DoubleO.WriteLn;
+  DoubleO.Free;
+end.
+