Browse Source

* don't endlessly recurse when printing the typename of a procvardef that
refers to itself via a pointerdef in its parameter or result type(s)
(mantis #25551)

git-svn-id: trunk@26610 -

Jonas Maebe 11 years ago
parent
commit
2adfb6cdda
3 changed files with 23 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 10 1
      compiler/symdef.pas
  3. 12 0
      tests/webtbs/tw25551.pp

+ 1 - 0
.gitattributes

@@ -13794,6 +13794,7 @@ tests/webtbs/tw25349.pp svneol=native#text/plain
 tests/webtbs/tw2536.pp svneol=native#text/plain
 tests/webtbs/tw25361.pp svneol=native#text/plain
 tests/webtbs/tw2540.pp svneol=native#text/plain
+tests/webtbs/tw25551.pp svneol=native#text/plain
 tests/webtbs/tw2561.pp svneol=native#text/plain
 tests/webtbs/tw2588.pp svneol=native#text/plain
 tests/webtbs/tw2589.pp svneol=native#text/plain

+ 10 - 1
compiler/symdef.pas

@@ -3072,7 +3072,16 @@ implementation
 
     function tpointerdef.GetTypeName : string;
       begin
-        GetTypeName:='^'+pointeddef.typename;
+        { parameter types and the resultdef of a procvardef can contain a
+          pointer to this procvardef itself, resulting in endless recursion ->
+          use the typesym's name instead if it exists (if it doesn't, such as
+          for anynonymous procedure types in macpas/iso mode, then there cannot
+          be any recursive references to it either) }
+        if (pointeddef.typ<>procvardef) or
+           not assigned(pointeddef.typesym) then
+          GetTypeName:='^'+pointeddef.typename
+        else
+          GetTypeName:='^'+pointeddef.typesym.realname;
 {$ifdef x86}
         if x86pointertyp<>default_x86_data_pointer_type then
           begin

+ 12 - 0
tests/webtbs/tw25551.pp

@@ -0,0 +1,12 @@
+{ %norun }
+
+type
+    PA = ^TA;
+    TA = function: PA;
+
+function start: PA;
+begin
+end;
+
+begin
+end.