Commit 9f2cb25e by Eric Botcazou Committed by Eric Botcazou

c-ada-spec.c (has_static_fields): Look only into fields.

	* c-ada-spec.c (has_static_fields): Look only into fields.
	(dump_generic_ada_node): Small tweak.
	(dump_nested_types): Look only into fields.
	(print_ada_declaration): Look only into methods.  Small tweak.
	(print_ada_struct_decl): Look only into fields.  Use DECL_VIRTUAL_P.

From-SVN: r250802
parent 73380438
2017-08-01 Eric Botcazou <ebotcazou@adacore.com>
* c-ada-spec.c (has_static_fields): Look only into fields.
(dump_generic_ada_node): Small tweak.
(dump_nested_types): Look only into fields.
(print_ada_declaration): Look only into methods. Small tweak.
(print_ada_struct_decl): Look only into fields. Use DECL_VIRTUAL_P.
2017-08-01 Eric Botcazou <ebotcazou@adacore.com>
* c-ada-spec.c (print_generic_ada_decl): Pass correctly-typed constant.
(dump_ada_function_declaration): Likewise.
(dump_generic_ada_node): Likewise.
......
......@@ -1052,13 +1052,11 @@ get_underlying_decl (tree type)
static bool
has_static_fields (const_tree type)
{
tree tmp;
if (!type || !RECORD_OR_UNION_TYPE_P (type))
return false;
for (tmp = TYPE_FIELDS (type); tmp; tmp = TREE_CHAIN (tmp))
if (DECL_NAME (tmp) && TREE_STATIC (tmp))
for (tree fld = TYPE_FIELDS (type); fld; fld = TREE_CHAIN (fld))
if (TREE_CODE (fld) == FIELD_DECL && DECL_NAME (fld) && TREE_STATIC (fld))
return true;
return false;
......@@ -2384,13 +2382,14 @@ dump_generic_ada_node (pretty_printer *buffer, tree node, tree type, int spc,
{
if (is_tagged_type (TREE_TYPE (node)))
{
tree tmp = TYPE_FIELDS (TREE_TYPE (node));
int first = 1;
/* Look for ancestors. */
for (; tmp; tmp = TREE_CHAIN (tmp))
for (tree fld = TYPE_FIELDS (TREE_TYPE (node));
fld;
fld = TREE_CHAIN (fld))
{
if (!DECL_NAME (tmp) && is_tagged_type (TREE_TYPE (tmp)))
if (!DECL_NAME (fld) && is_tagged_type (TREE_TYPE (fld)))
{
if (first)
{
......@@ -2400,8 +2399,8 @@ dump_generic_ada_node (pretty_printer *buffer, tree node, tree type, int spc,
else
pp_string (buffer, " and ");
dump_ada_decl_name
(buffer, TYPE_NAME (TREE_TYPE (tmp)), false);
dump_ada_decl_name (buffer, TYPE_NAME (TREE_TYPE (fld)),
false);
}
}
......@@ -2504,7 +2503,7 @@ dump_nested_types (pretty_printer *buffer, tree t, tree parent, bool forward,
dump_nested_type (buffer, field, t, parent, spc);
for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
if (!TYPE_NAME (TREE_TYPE (field)))
if (TREE_CODE (field) == FIELD_DECL && !TYPE_NAME (TREE_TYPE (field)))
dump_nested_type (buffer, field, t, parent, spc);
TREE_VISITED (t) = 1;
......@@ -2955,7 +2954,8 @@ print_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc)
if (is_constructor && RECORD_OR_UNION_TYPE_P (type))
for (tree fld = TYPE_FIELDS (type); fld; fld = DECL_CHAIN (fld))
if (cpp_check (fld, IS_ABSTRACT))
if (TREE_CODE (TREE_TYPE (fld)) == METHOD_TYPE
&& cpp_check (fld, IS_ABSTRACT))
{
is_abstract_class = true;
break;
......@@ -3020,18 +3020,20 @@ print_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc)
if (cpp_check
&& RECORD_OR_UNION_TYPE_P (TREE_TYPE (t)))
{
is_interface = -1;
bool has_fields = false;
/* Check that there are no fields other than the virtual table. */
for (tree fld = TYPE_FIELDS (TREE_TYPE (t));
fld; fld = TREE_CHAIN (fld))
fld;
fld = TREE_CHAIN (fld))
{
if (TREE_CODE (fld) == FIELD_DECL)
{
if (is_interface < 0 && DECL_VIRTUAL_P (fld))
if (!has_fields && DECL_VIRTUAL_P (fld))
is_interface = 1;
else
is_interface = 0;
has_fields = true;
}
else if (TREE_CODE (TREE_TYPE (fld)) == METHOD_TYPE
&& !DECL_ARTIFICIAL (fld))
......@@ -3212,10 +3214,10 @@ print_ada_struct_decl (pretty_printer *buffer, tree node, tree type, int spc,
field_num++;
}
}
else if (TREE_CODE (tmp) != TYPE_DECL && !TREE_STATIC (tmp))
else if (TREE_CODE (tmp) == FIELD_DECL && !TREE_STATIC (tmp))
{
/* Skip internal virtual table field. */
if (strncmp (IDENTIFIER_POINTER (DECL_NAME (tmp)), "_vptr", 5))
if (!DECL_VIRTUAL_P (tmp))
{
if (is_union)
{
......@@ -3306,7 +3308,9 @@ print_ada_struct_decl (pretty_printer *buffer, tree node, tree type, int spc,
/* Print the static fields of the structure, if any. */
for (tmp = TYPE_FIELDS (node); tmp; tmp = TREE_CHAIN (tmp))
{
if (DECL_NAME (tmp) && TREE_STATIC (tmp))
if (TREE_CODE (tmp) == FIELD_DECL
&& DECL_NAME (tmp)
&& TREE_STATIC (tmp))
{
if (need_semicolon)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment