瀏覽代碼

* for adding procdefs to forwarddefs check for the specialization flag instead of whether it's a full specialization; fixes implicit finalization handlers on x86_64-win64 not being found
+ added tests

git-svn-id: trunk@45646 -

svenbarth 5 年之前
父節點
當前提交
febeef03e4
共有 5 個文件被更改,包括 72 次插入1 次删除
  1. 3 0
      .gitattributes
  2. 1 1
      compiler/pparautl.pas
  3. 34 0
      tests/tbs/tb0673.pp
  4. 14 0
      tests/tbs/tb0674.pp
  5. 20 0
      tests/tbs/ub0674.pp

+ 3 - 0
.gitattributes

@@ -13306,6 +13306,8 @@ tests/tbs/tb0669.pp svneol=native#text/pascal
 tests/tbs/tb0670.pp svneol=native#text/pascal
 tests/tbs/tb0671.pp svneol=native#text/pascal
 tests/tbs/tb0672.pp svneol=native#text/pascal
+tests/tbs/tb0673.pp svneol=native#text/pascal
+tests/tbs/tb0674.pp svneol=native#text/pascal
 tests/tbs/ub0060.pp svneol=native#text/plain
 tests/tbs/ub0069.pp svneol=native#text/plain
 tests/tbs/ub0119.pp svneol=native#text/plain
@@ -13344,6 +13346,7 @@ tests/tbs/ub0506.pp svneol=native#text/plain
 tests/tbs/ub0569.pp svneol=native#text/pascal
 tests/tbs/ub0629.pp svneol=native#text/pascal
 tests/tbs/ub0635.pp svneol=native#text/pascal
+tests/tbs/ub0674.pp svneol=native#text/pascal
 tests/test/README.txt svneol=native#text/plain
 tests/test/alglib/t_testconvunit.pp svneol=native#text/plain
 tests/test/alglib/t_testcorrunit.pp svneol=native#text/plain

+ 1 - 1
compiler/pparautl.pas

@@ -775,7 +775,7 @@ implementation
 
         if assigned(currpd.struct) and
            (currpd.struct.symtable.moduleid<>current_module.moduleid) and
-           not currpd.is_specialization then
+           not (df_specialization in currpd.defoptions) then
           begin
             result:=false;
             exit;

+ 34 - 0
tests/tbs/tb0673.pp

@@ -0,0 +1,34 @@
+{ %NORUN }
+
+program tb0673;
+
+{$mode objfpc}
+
+type
+  TTest = class
+    generic procedure Test<T>;
+  end;
+
+generic procedure TTest.Test<T>;
+
+  procedure SubTest1; forward;
+
+  procedure SubTest2;
+  begin
+    SubTest1;
+  end;
+
+  procedure SubTest1;
+  begin
+
+  end;
+
+begin
+  SubTest2;
+end;
+
+var
+  t: TTest;
+begin
+  t.specialize Test<LongInt>;
+end.

+ 14 - 0
tests/tbs/tb0674.pp

@@ -0,0 +1,14 @@
+{ %NORUN }
+
+{$mode objfpc}{$H+}
+
+uses
+  ub0674;
+
+var
+  LaunchRequest: TObject;
+  c: TMyClass;
+begin
+  c:=TMyClass.Create;
+  LaunchRequest := c.specialize CreateObjectFromJSONString<TObject>('qwe');
+end.

+ 20 - 0
tests/tbs/ub0674.pp

@@ -0,0 +1,20 @@
+{$mode objfpc}{$H+}
+
+unit ub0674;
+
+interface
+
+type
+   TMyClass = class
+   public
+     generic function CreateObjectFromJSONString<T{: TObject}>(AJSONString: String; ADescriptionTag: string = ''): T;
+   end;
+
+implementation
+
+generic function TMyClass.CreateObjectFromJSONString<T>(AJSONString: String; ADescriptionTag: string): T;
+begin
+  Result:=Nil;//T.Create;
+end;
+
+end.