Browse Source

* fix for Mantis #31201: don't write any RTTI for undefined defs (and while we're at it abort if an error def is encountered)

+ added test

git-svn-id: trunk@35256 -
svenbarth 8 years ago
parent
commit
6b641394d0
3 changed files with 32 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 6 0
      compiler/ncgrtti.pas
  3. 25 0
      tests/webtbs/tw31201.pp

+ 1 - 0
.gitattributes

@@ -15334,6 +15334,7 @@ tests/webtbs/tw3109.pp svneol=native#text/plain
 tests/webtbs/tw3111.pp svneol=native#text/plain
 tests/webtbs/tw3111.pp svneol=native#text/plain
 tests/webtbs/tw31120.pp svneol=native#text/pascal
 tests/webtbs/tw31120.pp svneol=native#text/pascal
 tests/webtbs/tw3113.pp svneol=native#text/plain
 tests/webtbs/tw3113.pp svneol=native#text/plain
+tests/webtbs/tw31201.pp svneol=native#text/pascal
 tests/webtbs/tw3124.pp svneol=native#text/plain
 tests/webtbs/tw3124.pp svneol=native#text/plain
 tests/webtbs/tw3131.pp svneol=native#text/plain
 tests/webtbs/tw3131.pp svneol=native#text/plain
 tests/webtbs/tw3137.pp svneol=native#text/plain
 tests/webtbs/tw3137.pp svneol=native#text/plain

+ 6 - 0
compiler/ncgrtti.pas

@@ -136,6 +136,12 @@ implementation
                   if assigned(tprocdef(def).parast) then
                   if assigned(tprocdef(def).parast) then
                     write_persistent_type_info(tprocdef(def).parast,false);
                     write_persistent_type_info(tprocdef(def).parast,false);
                 end;
                 end;
+              errordef:
+                { we shouldn't have come this far if we have an errordef somewhere }
+                internalerror(2017010701);
+              undefineddef:
+                { don't write any RTTI for these }
+                continue;
             end;
             end;
             { always generate persistent tables for types in the interface so
             { always generate persistent tables for types in the interface so
               they can be reused in other units and give always the same pointer
               they can be reused in other units and give always the same pointer

+ 25 - 0
tests/webtbs/tw31201.pp

@@ -0,0 +1,25 @@
+unit tw31201;
+
+{$mode delphi}{$H+}
+
+interface
+
+type
+  Tuple<T> = record
+    Item1: T;
+  end;
+
+  Tuple = record
+    class function Create<T>(Item1: T): Tuple<T>; overload; static;
+  end;
+
+implementation
+
+class function Tuple.Create<T>(Item1: T): Tuple<T>;
+begin
+  Result.Item1:=Item1;
+end;
+
+initialization
+  Writeln(Tuple.Create<LongInt>(42).Item1);
+end.