2012-03-25 Eric Botcazou <ebotcazou@adacore.com>
+ * gcc-interface/utils.c (add_parallel_type): Take a TYPE instead of a
+ DECL and adjust. Move around.
+ (has_parallel_type): New predicate.
+ (rest_of_record_type_compilation): Return early if the type already
+ has a parallel type.
+ * gcc-interface/gigi.h (add_parallel_type): Adjust.
+ * gcc-interface/decl.c (gnat_to_gnu_entity): Adjust for above changes.
+
+2012-03-25 Eric Botcazou <ebotcazou@adacore.com>
+
* gcc-interface/utils.c (finish_record_type): Return early for padded
types and tidy up.
if (debug_info_p
&& Is_Packed_Array_Type (gnat_entity)
&& present_gnu_tree (Original_Array_Type (gnat_entity)))
- add_parallel_type (TYPE_STUB_DECL (gnu_type),
+ add_parallel_type (gnu_type,
gnat_to_gnu_type
(Original_Array_Type (gnat_entity)));
{
/* Make the original array type a parallel type. */
if (present_gnu_tree (Original_Array_Type (gnat_entity)))
- add_parallel_type (TYPE_STUB_DECL (gnu_type),
+ add_parallel_type (gnu_type,
gnat_to_gnu_type
(Original_Array_Type (gnat_entity)));
}
finish_record_type (gnu_bound_rec, gnu_field_list, 0, true);
- add_parallel_type (TYPE_STUB_DECL (gnu_type), gnu_bound_rec);
+ add_parallel_type (gnu_type, gnu_bound_rec);
}
/* If this is a packed array type, make the original array type a
{
if (Is_Packed_Array_Type (gnat_entity)
&& present_gnu_tree (Original_Array_Type (gnat_entity)))
- add_parallel_type (TYPE_STUB_DECL (gnu_type),
+ add_parallel_type (gnu_type,
gnat_to_gnu_type
(Original_Array_Type (gnat_entity)));
else
tree gnu_base_decl
= gnat_to_gnu_entity (Etype (gnat_entity), NULL_TREE, 0);
if (!DECL_ARTIFICIAL (gnu_base_decl))
- add_parallel_type (TYPE_STUB_DECL (gnu_type),
+ add_parallel_type (gnu_type,
TREE_TYPE (TREE_TYPE (gnu_base_decl)));
}
}
0, 0),
0, true);
- add_parallel_type (TYPE_STUB_DECL (gnu_type),
- gnu_subtype_marker);
+ add_parallel_type (gnu_type, gnu_subtype_marker);
if (definition
&& TREE_CODE (gnu_size_unit) != INTEGER_CST
0, 0),
0, true);
- add_parallel_type (TYPE_STUB_DECL (record), marker);
+ add_parallel_type (record, marker);
if (definition && size && TREE_CODE (size) != INTEGER_CST)
TYPE_SIZE_UNIT (marker)
a parallel type is to be attached to the record type. */
extern void rest_of_record_type_compilation (tree record_type);
-/* Append PARALLEL_TYPE on the chain of parallel types for decl. */
-extern void add_parallel_type (tree decl, tree parallel_type);
+/* Append PARALLEL_TYPE on the chain of parallel types for TYPE. */
+extern void add_parallel_type (tree type, tree parallel_type);
/* Return a FUNCTION_TYPE node. RETURN_TYPE is the type returned by the
subprogram. If it is VOID_TYPE, then we are dealing with a procedure,
rest_of_record_type_compilation (record_type);
}
+/* Append PARALLEL_TYPE on the chain of parallel types of TYPE. */
+
+void
+add_parallel_type (tree type, tree parallel_type)
+{
+ tree decl = TYPE_STUB_DECL (type);
+
+ while (DECL_PARALLEL_TYPE (decl))
+ decl = TYPE_STUB_DECL (DECL_PARALLEL_TYPE (decl));
+
+ SET_DECL_PARALLEL_TYPE (decl, parallel_type);
+}
+
+/* Return true if TYPE has a parallel type. */
+
+static bool
+has_parallel_type (tree type)
+{
+ tree decl = TYPE_STUB_DECL (type);
+
+ return DECL_PARALLEL_TYPE (decl) != NULL_TREE;
+}
+
/* Wrap up compilation of RECORD_TYPE, i.e. output all the debug information
associated with it. It need not be invoked directly in most cases since
finish_record_type takes care of doing so, but this can be necessary if
if (TYPE_IS_PADDING_P (record_type))
return;
+ /* If the type already has a parallel type (XVS type), then we're done. */
+ if (has_parallel_type (record_type))
+ return;
+
for (field = TYPE_FIELDS (record_type); field; field = DECL_CHAIN (field))
{
/* We need to make an XVE/XVU record if any field has variable size,
TYPE_FIELDS (new_record_type) = nreverse (TYPE_FIELDS (new_record_type));
- add_parallel_type (TYPE_STUB_DECL (record_type), new_record_type);
+ add_parallel_type (record_type, new_record_type);
}
}
-/* Append PARALLEL_TYPE on the chain of parallel types for decl. */
-
-void
-add_parallel_type (tree decl, tree parallel_type)
-{
- tree d = decl;
-
- while (DECL_PARALLEL_TYPE (d))
- d = TYPE_STUB_DECL (DECL_PARALLEL_TYPE (d));
-
- SET_DECL_PARALLEL_TYPE (d, parallel_type);
-}
-
/* Utility function of above to merge LAST_SIZE, the previous size of a record
with FIRST_BIT and SIZE that describe a field. SPECIAL is true if this
represents a QUAL_UNION_TYPE in which case we must look for COND_EXPRs and