aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2025-09-08 19:41:20 +0200
committerEric Botcazou <ebotcazou@adacore.com>2025-09-08 19:41:20 +0200
commit5ee35b12de830a4688e79ed7ab464f281a220d3d (patch)
tree45cf0bcbcf023bcfec6293d3eda94bea34986ba3 /gcc
parent7640cc5ef80afae9b65afcca96e1eb2b9e513c21 (diff)
downloadgcc-5ee35b12de830a4688e79ed7ab464f281a220d3d.zip
gcc-5ee35b12de830a4688e79ed7ab464f281a220d3d.tar.gz
gcc-5ee35b12de830a4688e79ed7ab464f281a220d3d.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-family/c-ada-spec.cc26
1 files changed, 23 insertions, 3 deletions
diff --git a/gcc/c-family/c-ada-spec.cc b/gcc/c-family/c-ada-spec.cc
index c7ae032..42d75b4 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