[Ada] Fix handling of incomplete types with -fdump-ada-spec (1/2)

Eric Botcazou ebotcazou@adacore.com
Wed Feb 28 13:44:00 GMT 2018


In some cases, when a type is still incomplete, a pointer to this type will be 
translated as System.Address by -fdump-ada-spec, which is slightly annoying.
This fixes most of these cases and generates proper access types instead.

Tested on x86_64-suse-linux, applied on the mainline.


2018-02-28  Eric Botcazou  <ebotcazou@adacore.com>

c-family/
	* c-ada-spec.c (dump_ada_import): Use boolean and fix formatting.
	(is_char_array): Fix formatting.
	(dump_template_types): Likewise.
	(dump_generic_ada_node): Rename into...
	(dump_ada_node): ...this.
	<POINTER_TYPE>: Remove superfluous space.  Use generic address for
	incomplete structures and not for empty structures.  Do not use it
	when forward declarations are needed.
	(dump_forward_type): New function.
	(dump_nested_types): Remove FORWARD parameter.  Do not consider
	TREE_VISITED and do not generate a forward declaration.  Only dump
	original nested types for nested declaration.
	(dump_nested_type) <POINTER_TYPE>: Call dump_forward_type.
	<ARRAY_TYPE>: Likewise if the component type is an anonymous pointer.
	<RECORD_TYPE>: Do not consider TREE_VISITED.
	(dump_ada_declaration): Use booleans and fix formatting throughout.
	<TYPE_DECL>: Skip incomplete structures and not empty structures.
	Call dump_forward_type instead of dump_nested_types for a typedef.
	Remove superfluous check and adjust call to dump_nested_types.
	<POINTER_TYPE>: Call dump_forward_type and fall through.
	(dump_ada_struct_decl): Rename into...
	(dump_ada_structure): ...this.  Do not special-case empty structures.


2018-02-28  Eric Botcazou  <ebotcazou@adacore.com>

	* c-c++-common/dump-ada-spec-8.c: New test.
	* c-c++-common/dump-ada-spec-9.c: Likewise.
	* c-c++-common/dump-ada-spec-10.c: Likewise.

-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p1.diff
Type: text/x-patch
Size: 18369 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20180228/1f1840ea/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dump-ada-spec-8.c
Type: text/x-csrc
Size: 270 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20180228/1f1840ea/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dump-ada-spec-9.c
Type: text/x-csrc
Size: 248 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20180228/1f1840ea/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dump-ada-spec-10.c
Type: text/x-csrc
Size: 282 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20180228/1f1840ea/attachment-0003.bin>


More information about the Gcc-patches mailing list