[gcc r16-3670] Ada: Make -fdump-ada-spec deal with pointers to anonymous structure
Eric Botcazou
ebotcazou@gcc.gnu.org
Mon Sep 8 17:45:13 GMT 2025
https://gcc.gnu.org/g:5ee35b12de830a4688e79ed7ab464f281a220d3d
commit r16-3670-g5ee35b12de830a4688e79ed7ab464f281a220d3d
Author: Eric Botcazou <ebotcazou@adacore.com>
Date: Mon Sep 8 19:41:20 2025 +0200
Ada: Make -fdump-ada-spec deal with pointers to anonymous structure
This is about -fdump-ada-spec not generating the definition of the structure
for pointers to anonymous structure as structure elements.
gcc/c-family:
PR ada/121544
* c-ada-spec.cc (dump_ada_node) <POINTER_TYPE>: Dump the name of
anonymous tagged pointed-to types specially.
(dump_nested_type) <POINTER_TYPE>: Recurse on anonymous pointed-to
types declared in the same file.
Set TREE_VISITED on the underlying DECL of the field type, if any.
Diff:
---
gcc/c-family/c-ada-spec.cc | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/gcc/c-family/c-ada-spec.cc b/gcc/c-family/c-ada-spec.cc
index c7ae032230a8..42d75b49c94e 100644
--- a/gcc/c-family/c-ada-spec.cc
+++ b/gcc/c-family/c-ada-spec.cc
@@ -2442,8 +2442,14 @@ dump_ada_node (pretty_printer *pp, tree node, tree type, int spc,
break;
}
- dump_ada_node (pp, ref_type, ref_type, spc, is_access,
- true);
+ /* Dump anonymous tagged types specially. */
+ if (TYPE_NAME (ref_type)
+ || (!RECORD_OR_UNION_TYPE_P (ref_type)
+ && TREE_CODE (ref_type) != ENUMERAL_TYPE))
+ dump_ada_node (pp, ref_type, ref_type, spc, is_access,
+ true);
+ else
+ dump_anonymous_type_name (pp, ref_type);
}
}
}
@@ -2699,7 +2705,16 @@ dump_nested_type (pretty_printer *pp, tree field, tree t, int spc)
{
case POINTER_TYPE:
tmp = TREE_TYPE (field_type);
- dump_forward_type (pp, tmp, t, spc);
+ decl = get_underlying_decl (tmp);
+ if (TYPE_NAME (tmp) || !decl || DECL_NAME (decl))
+ dump_forward_type (pp, tmp, t, spc);
+ else if (DECL_SOURCE_FILE (decl) == DECL_SOURCE_FILE (t)
+ && !TREE_VISITED (decl))
+ {
+ /* Generate full declaration. */
+ dump_nested_type (pp, decl, t, spc);
+ TREE_VISITED (decl) = 1;
+ }
break;
case ARRAY_TYPE:
@@ -2773,6 +2788,11 @@ dump_nested_type (pretty_printer *pp, tree field, tree t, int spc)
default:
break;
}
+
+ /* Make sure not to output the nested type twice in C++. */
+ decl = get_underlying_decl (field_type);
+ if (decl)
+ TREE_VISITED (decl) = 1;
}
/* Hash table of overloaded names that we cannot support. It is needed even
More information about the Gcc-cvs
mailing list