Browse Source

* second fix for Mantis #31033: also check for df_specialization instead of is_specialization for parameters to correctly handle nested types that aren't really true specializations themselves
+ added additional test

git-svn-id: trunk@35103 -

svenbarth 8 years ago
parent
commit
5fa181b5d9
3 changed files with 38 additions and 2 deletions
  1. 1 0
      .gitattributes
  2. 2 2
      compiler/defcmp.pas
  3. 35 0
      tests/webtbs/tw31033b.pp

+ 1 - 0
.gitattributes

@@ -15306,6 +15306,7 @@ 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/tw31033b.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

+ 2 - 2
compiler/defcmp.pas

@@ -2154,8 +2154,8 @@ implementation
                   else
                     { for the purpose of forward declarations two equal specializations
                       are considered as exactly equal }
-                    if tstoreddef(currpara1.vardef).is_specialization and
-                        tstoreddef(currpara2.vardef).is_specialization then
+                    if (df_specialization in tstoreddef(currpara1.vardef).defoptions) and
+                        (df_specialization in tstoreddef(currpara2.vardef).defoptions) then
                       eq:=te_exact;
                 end;
               { open strings can never match exactly, since you cannot define }

+ 35 - 0
tests/webtbs/tw31033b.pp

@@ -0,0 +1,35 @@
+{ %NORUN }
+
+program tw31033;
+
+{$MODESWITCH RESULT}
+{$MODESWITCH ADVANCEDRECORDS}
+{$MODESWITCH OUT}
+
+Type
+  generic TGData<T> = record
+    public type
+      PGData = ^specialize TGData<T>;
+
+    public
+      b: T;
+      n: PGData;
+  end;
+
+generic Procedure DoSomething<T>(out p: specialize TGData<T>.PGData); forward;
+
+generic Procedure DoSomething<T>(out p: specialize TGData<T>.PGData);
+  Begin
+    new(p);
+
+    p^.b := default(T);
+    p^.n := nil
+  End;
+
+var
+  pl: specialize TGData<LongInt>.PGData;
+  ps: specialize TGData<ShortString>.PGData;
+begin
+  specialize DoSomething<LongInt>(pl);
+  specialize DoSomething<ShortString>(pl);
+end.