Fix duplicates for anonymous structures with -fdump-ada-spec
authorEric Botcazou <ebotcazou@gcc.gnu.org>
Fri, 14 Feb 2020 23:11:04 +0000 (00:11 +0100)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Fri, 14 Feb 2020 23:13:18 +0000 (00:13 +0100)
commit1d757b0950831ee9e223b3159e9d44461b6dbdd2
tree37aacbe9a28f7d755d8ae49bb049be25ff6b3ae4
parentc26007ab17278729b8ba8eedd621cfb64b7e13d2
Fix duplicates for anonymous structures with -fdump-ada-spec

This fixes a weakness in the way -fdump-ada-spec builds names for
anonymous structures in the C/C++ code, resulting in duplicate
identifiers under specific circumstances.

c-family/
* c-ada-spec.c: Include bitmap.h.
(dump_ada_double_name): Rename into...
(dump_anonymous_type_name): ...this.  Always use the TYPE_UID.
(dump_ada_array_type): Adjust to above renaming.  Robustify.
(dump_nested_types_1): New function copied from...  Add
dumped_types parameter and pass it down to dump_nested_type.
(dump_nested_types): ...this.  Remove parent parameter.  Just
call dump_nested_types_1 on an automatic bitmap.
(dump_nested_type): Add dumped_types parameter.
<ARRAY_TYPE>: Do not dump it if already present in dumped_types.
Adjust recursive calls and adjust to above renaming.
(dump_ada_declaration): Adjust call to dump_nested_types.
Tidy up and adjust to above renaming.
(dump_ada_specs): Initialize and release bitmap obstack.
gcc/c-family/ChangeLog
gcc/c-family/c-ada-spec.c