]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix crash on circular array types with -fdump switches
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 4 Jul 2022 10:16:38 +0000 (12:16 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Mon, 4 Jul 2022 10:23:37 +0000 (12:23 +0200)
Such questionable arrays types can occur in Ada.

gcc/
* tree-pretty-print.cc (dump_generic_node) <ARRAY_TYPE>: Add guard
for direct circularity.

gcc/tree-pretty-print.cc

index bfabe9e76279d7c3383b684ed61cc92228de4500..47371d8bcbebf38b1e2c8a725bab99cece8f14d6 100644 (file)
@@ -2077,7 +2077,11 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags,
        for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
             tmp = TREE_TYPE (tmp))
          ;
-       dump_generic_node (pp, tmp, spc, flags, false);
+
+       /* Avoid to print recursively the array.  */
+       /* FIXME : Not implemented correctly, see print_struct_decl.  */
+       if (TREE_CODE (tmp) != POINTER_TYPE || TREE_TYPE (tmp) != node)
+         dump_generic_node (pp, tmp, spc, flags, false);
 
        /* Print the dimensions.  */
        for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))