Browse Source

* fix for Mantis #31033: don't check for is_specialization(), but for df_specialization (this way we also get pointers or nested types that aren't by themselves real specializations)
+ added test

git-svn-id: trunk@35092 -

svenbarth 8 năm trước cách đây
mục cha
commit
52673d34f1
3 tập tin đã thay đổi với 40 bổ sung1 xóa
  1. 1 0
      .gitattributes
  2. 1 1
      compiler/pdecsub.pas
  3. 38 0
      tests/webtbs/tw31033.pp

+ 1 - 0
.gitattributes

@@ -15300,6 +15300,7 @@ tests/webtbs/tw30978.pp svneol=native#text/pascal
 tests/webtbs/tw30978a.pp svneol=native#text/pascal
 tests/webtbs/tw3101.pp svneol=native#text/plain
 tests/webtbs/tw31029.pp svneol=native#text/pascal
+tests/webtbs/tw31033.pp svneol=native#text/pascal
 tests/webtbs/tw3104.pp svneol=native#text/plain
 tests/webtbs/tw31076.pp svneol=native#text/pascal
 tests/webtbs/tw3109.pp svneol=native#text/plain

+ 1 - 1
compiler/pdecsub.pas

@@ -3395,7 +3395,7 @@ const
             exit;
           if not foundretdef then
             begin
-              if tstoreddef(fwpd.returndef).is_specialization and tstoreddef(currpd.returndef).is_specialization then
+              if (df_specialization in tstoreddef(fwpd.returndef).defoptions) and (df_specialization in tstoreddef(currpd.returndef).defoptions) then
                 { for specializations we're happy with equal defs instead of exactly the same defs }
                 result:=equal_defs(fwpd.returndef,currpd.returndef)
               else

+ 38 - 0
tests/webtbs/tw31033.pp

@@ -0,0 +1,38 @@
+{ %NORUN }
+
+program tw31033;
+
+{$MODESWITCH RESULT}
+{$MODESWITCH ADVANCEDRECORDS}
+
+Type
+  generic TGData<T> = record
+    public type
+      // FIXME: Compiler bug, details see:
+      // http://lists.freepascal.org/pipermail/fpc-pascal/2016-November/049444.html [^]
+
+      TSelf = specialize TGData<T>;
+
+      PSelf = ^TSelf;
+
+    public
+      d: T;
+      n: PSelf
+  end;
+
+generic Function Init<T>: specialize TGData<T>.PSelf; forward;
+
+generic Function Init<T>: specialize TGData<T>.PSelf;
+  Begin
+    new(result);
+
+    result^.d := default(T);
+    result^.n := nil
+  End;
+
+var
+  t: ^specialize TGData<LongInt>;
+Begin
+  t := specialize Init<LongInt>;
+  dispose(t);
+End.