}
}
\f
-/* GNAT_ENTITY is the type of the resulting constructors,
- GNAT_ASSOC is the front of the Component_Associations of an N_Aggregate,
- and GNU_TYPE is the GCC type of the corresponding record.
-
- Return a CONSTRUCTOR to build the record. */
+/* GNAT_ENTITY is the type of the resulting constructor, GNAT_ASSOC is the
+ front of the Component_Associations of an N_Aggregate and GNU_TYPE is the
+ GCC type of the corresponding record type. Return the CONSTRUCTOR. */
static tree
assoc_to_constructor (Entity_Id gnat_entity, Node_Id gnat_assoc, tree gnu_type)
{
- tree gnu_list, gnu_result;
+ tree gnu_list = NULL_TREE, gnu_result;
/* We test for GNU_FIELD being empty in the case where a variant
was the last thing since we don't take things off GNAT_ASSOC in
that case. We check GNAT_ASSOC in case we have a variant, but it
has no fields. */
- for (gnu_list = NULL_TREE; Present (gnat_assoc);
- gnat_assoc = Next (gnat_assoc))
+ for (; Present (gnat_assoc); gnat_assoc = Next (gnat_assoc))
{
Node_Id gnat_field = First (Choices (gnat_assoc));
tree gnu_field = gnat_to_gnu_field_decl (Entity (gnat_field));
continue;
/* Also ignore discriminants of Unchecked_Unions. */
- else if (Is_Unchecked_Union (gnat_entity)
- && Ekind (Entity (gnat_field)) == E_Discriminant)
+ if (Is_Unchecked_Union (gnat_entity)
+ && Ekind (Entity (gnat_field)) == E_Discriminant)
continue;
/* Before assigning a value in an aggregate make sure range checks
gnu_result = extract_values (gnu_list, gnu_type);
#ifdef ENABLE_CHECKING
- {
- tree gnu_field;
-
- /* Verify every entry in GNU_LIST was used. */
- for (gnu_field = gnu_list; gnu_field; gnu_field = TREE_CHAIN (gnu_field))
- gcc_assert (TREE_ADDRESSABLE (gnu_field));
- }
+ /* Verify that every entry in GNU_LIST was used. */
+ for (; gnu_list; gnu_list = TREE_CHAIN (gnu_list))
+ gcc_assert (TREE_ADDRESSABLE (gnu_list));
#endif
return gnu_result;
gcc_assert ((TREE_CODE (record_type) == RECORD_TYPE
|| TREE_CODE (record_type) == UNION_TYPE
|| TREE_CODE (record_type) == QUAL_UNION_TYPE)
- && TYPE_SIZE (record_type)
- && (component != 0) != (field != 0));
+ && COMPLETE_TYPE_P (record_type)
+ && (component == NULL_TREE) != (field == NULL_TREE));
- /* If no field was specified, look for a field with the specified name
- in the current record only. */
+ /* If no field was specified, look for a field with the specified name in
+ the current record only. */
if (!field)
- for (field = TYPE_FIELDS (record_type); field;
- field = TREE_CHAIN (field))
+ for (field = TYPE_FIELDS (record_type);
+ field;
+ field = DECL_CHAIN (field))
if (DECL_NAME (field) == component)
break;
tree new_field;
/* First loop thru normal components. */
- for (new_field = TYPE_FIELDS (record_type); new_field;
+ for (new_field = TYPE_FIELDS (record_type);
+ new_field;
new_field = DECL_CHAIN (new_field))
if (SAME_FIELD_P (field, new_field))
break;
return ref;
}
- /* Next, loop thru DECL_INTERNAL_P components if we haven't found
- the component in the first search. Doing this search in 2 steps
- is required to avoiding hidden homonymous fields in the
- _Parent field. */
+ /* Next, loop thru DECL_INTERNAL_P components if we haven't found the
+ component in the first search. Doing this search in two steps is
+ required to avoid hidden homonymous fields in the _Parent field. */
if (!new_field)
- for (new_field = TYPE_FIELDS (record_type); new_field;
+ for (new_field = TYPE_FIELDS (record_type);
+ new_field;
new_field = DECL_CHAIN (new_field))
if (DECL_INTERNAL_P (new_field))
{
NULL_TREE, new_field, no_fold_p);
ref = build_simple_component_ref (field_ref, NULL_TREE, field,
no_fold_p);
-
if (ref)
return ref;
}
if (!field)
return NULL_TREE;
- /* If the field's offset has overflowed, do not attempt to access it
- as doing so may trigger sanity checks deeper in the back-end.
- Note that we don't need to warn since this will be done on trying
- to declare the object. */
+ /* If the field's offset has overflowed, do not try to access it, as doing
+ so may trigger sanity checks deeper in the back-end. Note that we don't
+ need to warn since this will be done on trying to declare the object. */
if (TREE_CODE (DECL_FIELD_OFFSET (field)) == INTEGER_CST
&& TREE_OVERFLOW (DECL_FIELD_OFFSET (field)))
return NULL_TREE;
- /* Look through conversion between type variants. Note that this
- is transparent as far as the field is concerned. */
+ /* Look through conversion between type variants. This is transparent as
+ far as the field is concerned. */
if (TREE_CODE (record_variable) == VIEW_CONVERT_EXPR
&& TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (record_variable, 0)))
== record_type)
ref = build3 (COMPONENT_REF, TREE_TYPE (field), inner_variable, field,
NULL_TREE);
- if (TREE_READONLY (record_variable) || TREE_READONLY (field))
+ if (TREE_READONLY (record_variable)
+ || TREE_READONLY (field)
+ || TYPE_READONLY (record_type))
TREE_READONLY (ref) = 1;
- if (TREE_THIS_VOLATILE (record_variable) || TREE_THIS_VOLATILE (field)
+
+ if (TREE_THIS_VOLATILE (record_variable)
+ || TREE_THIS_VOLATILE (field)
|| TYPE_VOLATILE (record_type))
TREE_THIS_VOLATILE (ref) = 1;
/* The generic folder may punt in this case because the inner array type
can be self-referential, but folding is in fact not problematic. */
- else if (TREE_CODE (record_variable) == CONSTRUCTOR
- && TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (record_variable)))
+ if (TREE_CODE (record_variable) == CONSTRUCTOR
+ && TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (record_variable)))
{
VEC(constructor_elt,gc) *elts = CONSTRUCTOR_ELTS (record_variable);
unsigned HOST_WIDE_INT idx;
return ref;
}
- else
- return fold (ref);
+ return fold (ref);
}
\f
/* Like build_simple_component_ref, except that we give an error if the