Commit 79714815 by Eric Botcazou Committed by Eric Botcazou

utils.c (gnat_pushdecl): Reunify the handling of array and pointer types wrt…

utils.c (gnat_pushdecl): Reunify the handling of array and pointer types wrt DECL_ORIGINAL_TYPE and...

	* gcc-interface/utils.c (gnat_pushdecl): Reunify the handling of array
	and pointer types wrt DECL_ORIGINAL_TYPE and adjust left and right.

From-SVN: r223835
parent fc7a823e
2015-05-28 Eric Botcazou <ebotcazou@adacore.com> 2015-05-28 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/utils.c (gnat_pushdecl): Reunify the handling of array
and pointer types wrt DECL_ORIGINAL_TYPE and adjust left and right.
2015-05-28 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/gigi.h (gnat_stabilize_reference): Adjust. * gcc-interface/gigi.h (gnat_stabilize_reference): Adjust.
(rewrite_fn): Remove third parameter. (rewrite_fn): Remove third parameter.
(type_is_padding_self_referential): New inline predicate. (type_is_padding_self_referential): New inline predicate.
......
...@@ -776,31 +776,21 @@ gnat_pushdecl (tree decl, Node_Id gnat_node) ...@@ -776,31 +776,21 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
{ {
tree t = TREE_TYPE (decl); tree t = TREE_TYPE (decl);
/* Array and pointer types aren't tagged types in the C sense so we need
to generate a typedef in DWARF for them and make sure it is preserved,
unless the type is artificial. */
if (!(TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL) if (!(TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL)
&& (TREE_CODE (t) != POINTER_TYPE || DECL_ARTIFICIAL (decl))) && ((TREE_CODE (t) != ARRAY_TYPE && TREE_CODE (t) != POINTER_TYPE)
{ || DECL_ARTIFICIAL (decl)))
/* Array types aren't "tagged" types so we force the type to be ;
associated with its typedef in the DWARF back-end, in order to /* For array and pointer types, create the DECL_ORIGINAL_TYPE that will
make sure that the latter is always preserved, by creating an generate the typedef in DWARF. Also do that for fat pointer types
on-side copy for DECL_ORIGINAL_TYPE. We used to do the same because, even though they are tagged types in the C sense, they are
for pointer types, but to have consistent DWARF output we now still XUP types attached to the base array type at this point. */
create a copy for the type itself and use the original type
for DECL_ORIGINAL_TYPE like the C front-end. */
if (!DECL_ARTIFICIAL (decl) && TREE_CODE (t) == ARRAY_TYPE)
{
tree tt = build_distinct_type_copy (t);
/* Array types need to have a name so that they can be related
to their GNAT encodings. */
TYPE_NAME (tt) = DECL_NAME (decl);
defer_or_set_type_context (tt,
DECL_CONTEXT (decl),
deferred_decl_context);
TYPE_STUB_DECL (tt) = TYPE_STUB_DECL (t);
DECL_ORIGINAL_TYPE (decl) = tt;
}
}
else if (!DECL_ARTIFICIAL (decl) else if (!DECL_ARTIFICIAL (decl)
&& (TREE_CODE (t) == POINTER_TYPE || TYPE_IS_FAT_POINTER_P (t))) && (TREE_CODE (t) == ARRAY_TYPE
|| TREE_CODE (t) == POINTER_TYPE
|| TYPE_IS_FAT_POINTER_P (t)))
{ {
tree tt; tree tt;
/* ??? Copy and original type are not supposed to be variant but we /* ??? Copy and original type are not supposed to be variant but we
...@@ -811,7 +801,8 @@ gnat_pushdecl (tree decl, Node_Id gnat_node) ...@@ -811,7 +801,8 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
{ {
/* TYPE_NEXT_PTR_TO is a chain of main variants. */ /* TYPE_NEXT_PTR_TO is a chain of main variants. */
tt = build_distinct_type_copy (TYPE_MAIN_VARIANT (t)); tt = build_distinct_type_copy (TYPE_MAIN_VARIANT (t));
TYPE_NEXT_PTR_TO (TYPE_MAIN_VARIANT (t)) = tt; if (TREE_CODE (t) == POINTER_TYPE)
TYPE_NEXT_PTR_TO (TYPE_MAIN_VARIANT (t)) = tt;
tt = build_qualified_type (tt, TYPE_QUALS (t)); tt = build_qualified_type (tt, TYPE_QUALS (t));
} }
TYPE_NAME (tt) = decl; TYPE_NAME (tt) = decl;
...@@ -820,29 +811,36 @@ gnat_pushdecl (tree decl, Node_Id gnat_node) ...@@ -820,29 +811,36 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
deferred_decl_context); deferred_decl_context);
TREE_USED (tt) = TREE_USED (t); TREE_USED (tt) = TREE_USED (t);
TREE_TYPE (decl) = tt; TREE_TYPE (decl) = tt;
if (TYPE_NAME (t) != NULL_TREE if (TYPE_NAME (t)
&& TREE_CODE (TYPE_NAME (t)) == TYPE_DECL && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL
&& DECL_ORIGINAL_TYPE (TYPE_NAME (t))) && DECL_ORIGINAL_TYPE (TYPE_NAME (t)))
DECL_ORIGINAL_TYPE (decl) = DECL_ORIGINAL_TYPE (TYPE_NAME (t)); DECL_ORIGINAL_TYPE (decl) = DECL_ORIGINAL_TYPE (TYPE_NAME (t));
else else
DECL_ORIGINAL_TYPE (decl) = t; DECL_ORIGINAL_TYPE (decl) = t;
/* Array types need to have a name so that they can be related to
their GNAT encodings. */
if (TREE_CODE (t) == ARRAY_TYPE && !TYPE_NAME (t))
TYPE_NAME (t) = DECL_NAME (decl);
t = NULL_TREE; t = NULL_TREE;
} }
else if (TYPE_NAME (t) != NULL_TREE else if (TYPE_NAME (t)
&& TREE_CODE (TYPE_NAME (t)) == TYPE_DECL && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL
&& DECL_ARTIFICIAL (TYPE_NAME (t)) && !DECL_ARTIFICIAL (decl)) && DECL_ARTIFICIAL (TYPE_NAME (t)) && !DECL_ARTIFICIAL (decl))
; ;
else else
t = NULL_TREE; t = NULL_TREE;
/* Propagate the name to all the anonymous variants. This is needed /* Propagate the name to all the variants, this is needed for the type
for the type qualifiers machinery to work properly (see qualifiers machinery to work properly (see check_qualified_type).
check_qualified_type). Also propagate the context to them. Note that Also propagate the context to them. Note that it will be propagated
the context will be propagated to all parallel types too thanks to to all parallel types too thanks to gnat_set_type_context. */
gnat_set_type_context. */
if (t) if (t)
for (t = TYPE_MAIN_VARIANT (t); t; t = TYPE_NEXT_VARIANT (t)) for (t = TYPE_MAIN_VARIANT (t); t; t = TYPE_NEXT_VARIANT (t))
if (!(TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL)) /* ??? Because of the previous kludge, we can have variants of fat
pointer types with different names. */
if (!(TYPE_IS_FAT_POINTER_P (t)
&& TYPE_NAME (t)
&& TREE_CODE (TYPE_NAME (t)) == TYPE_DECL))
{ {
TYPE_NAME (t) = decl; TYPE_NAME (t) = decl;
defer_or_set_type_context (t, defer_or_set_type_context (t,
......
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