static tree gnat_to_gnu_param (Entity_Id, Mechanism_Type, Entity_Id, bool,
bool *);
static tree gnat_to_gnu_field (Entity_Id, tree, int, bool, bool);
+static tree change_qualified_type (tree, int);
static bool same_discriminant_p (Entity_Id, Entity_Id);
static bool array_type_has_nonaliased_component (tree, Entity_Id);
static bool compile_time_known_address_p (Node_Id);
Note that we need to preserve the volatility of the renamed
object through the indirection. */
if (TREE_THIS_VOLATILE (gnu_expr) && !TYPE_VOLATILE (gnu_type))
- gnu_type = build_qualified_type (gnu_type,
- (TYPE_QUALS (gnu_type)
- | TYPE_QUAL_VOLATILE));
+ gnu_type
+ = change_qualified_type (gnu_type, TYPE_QUAL_VOLATILE);
gnu_type = build_reference_type (gnu_type);
inner_const_flag = TREE_READONLY (gnu_expr);
const_flag = true;
|| imported_p
|| Present (Address_Clause (gnat_entity)))))
&& !TYPE_VOLATILE (gnu_type))
- gnu_type = build_qualified_type (gnu_type,
- (TYPE_QUALS (gnu_type)
- | TYPE_QUAL_VOLATILE));
+ gnu_type = change_qualified_type (gnu_type, TYPE_QUAL_VOLATILE);
/* If we are defining an aliased object whose nominal subtype is
unconstrained, the object is a record that contains both the
}
if (const_flag)
- gnu_type = build_qualified_type (gnu_type, (TYPE_QUALS (gnu_type)
- | TYPE_QUAL_CONST));
+ gnu_type = change_qualified_type (gnu_type, TYPE_QUAL_CONST);
/* Convert the expression to the type of the object except in the
case where the object's type is unconstrained or the object's type
SET_TYPE_MODE (tem, BLKmode);
}
+ TYPE_VOLATILE (tem) = Treat_As_Volatile (gnat_entity);
+
/* If an alignment is specified, use it if valid. But ignore it
for the original type of packed array types. If the alignment
was requested with an explicit alignment clause, state so. */
SET_TYPE_MODE (gnu_type, BLKmode);
}
+ TYPE_VOLATILE (gnu_type) = Treat_As_Volatile (gnat_entity);
+
/* Attach the TYPE_STUB_DECL in case we have a parallel type. */
TYPE_STUB_DECL (gnu_type)
= create_type_stub_decl (gnu_entity_name, gnu_type);
process_attributes (&gnu_type, &attr_list, false, gnat_entity);
if (Treat_As_Volatile (gnat_entity))
gnu_type
- = build_qualified_type (gnu_type,
- TYPE_QUALS (gnu_type)
- | TYPE_QUAL_VOLATILE);
+ = change_qualified_type (gnu_type, TYPE_QUAL_VOLATILE);
/* Make it artificial only if the base type was artificial too.
That's sort of "morally" true and will make it possible for
the debugger to look it up by name in DWARF, which is needed
&& Is_By_Reference_Type (gnat_entity))
SET_TYPE_MODE (gnu_type, BLKmode);
- /* We used to remove the associations of the discriminants and _Parent
- for validity checking but we may need them if there's a Freeze_Node
- for a subtype used in this record. */
TYPE_VOLATILE (gnu_type) = Treat_As_Volatile (gnat_entity);
/* Fill in locations of fields. */
&& TREE_CODE (gnu_desig_type) != UNCONSTRAINED_ARRAY_TYPE)
{
gnu_desig_type
- = build_qualified_type
- (gnu_desig_type,
- TYPE_QUALS (gnu_desig_type) | TYPE_QUAL_CONST);
+ = change_qualified_type (gnu_desig_type, TYPE_QUAL_CONST);
/* Some extra processing is required if we are building a
pointer to an incomplete type (in the GCC sense). We might
if (TREE_CODE (gnu_return_type) == VOID_TYPE)
const_flag = false;
- gnu_type
- = build_qualified_type (gnu_type,
- TYPE_QUALS (gnu_type)
- | (TYPE_QUAL_CONST * const_flag)
- | (TYPE_QUAL_VOLATILE * volatile_flag));
+ if (const_flag || volatile_flag)
+ {
+ const int quals
+ = (const_flag ? TYPE_QUAL_CONST : 0)
+ | (volatile_flag ? TYPE_QUAL_VOLATILE : 0);
- if (has_stub)
- gnu_stub_type
- = build_qualified_type (gnu_stub_type,
- TYPE_QUALS (gnu_stub_type)
- | (TYPE_QUAL_CONST * const_flag)
- | (TYPE_QUAL_VOLATILE * volatile_flag));
+ gnu_type = change_qualified_type (gnu_type, quals);
+
+ if (has_stub)
+ gnu_stub_type = change_qualified_type (gnu_stub_type, quals);
+ }
/* If we have a builtin decl for that function, use it. Check if the
profiles are compatible and warn if they are not. The checker is
gnu_size = NULL_TREE;
}
- /* If the alignment hasn't already been processed and this is
- not an unconstrained array, see if an alignment is specified.
+ /* If the alignment has not already been processed and this is not
+ an unconstrained array type, see if an alignment is specified.
If not, we pick a default alignment for atomic objects. */
if (align != 0 || TREE_CODE (gnu_type) == UNCONSTRAINED_ARRAY_TYPE)
;
}
}
- if (Treat_As_Volatile (gnat_entity))
- gnu_type
- = build_qualified_type (gnu_type,
- TYPE_QUALS (gnu_type) | TYPE_QUAL_VOLATILE);
-
if (Is_Atomic (gnat_entity))
check_ok_for_atomic (gnu_type, gnat_entity, false);
- if (Present (Alignment_Clause (gnat_entity)))
- TYPE_USER_ALIGN (gnu_type) = 1;
+ /* If this is not an unconstrained array type, set some flags. */
+ if (TREE_CODE (gnu_type) != UNCONSTRAINED_ARRAY_TYPE)
+ {
+ if (Treat_As_Volatile (gnat_entity))
+ gnu_type = change_qualified_type (gnu_type, TYPE_QUAL_VOLATILE);
- if (Universal_Aliasing (gnat_entity))
- TYPE_UNIVERSAL_ALIASING_P (TYPE_MAIN_VARIANT (gnu_type)) = 1;
+ if (Present (Alignment_Clause (gnat_entity)))
+ TYPE_USER_ALIGN (gnu_type) = 1;
+
+ if (Universal_Aliasing (gnat_entity))
+ TYPE_UNIVERSAL_ALIASING_P (TYPE_MAIN_VARIANT (gnu_type)) = 1;
+ }
if (!gnu_decl)
gnu_decl = create_type_decl (gnu_entity_name, gnu_type,
}
if (Has_Volatile_Components (gnat_array))
- gnu_type
- = build_qualified_type (gnu_type,
- TYPE_QUALS (gnu_type) | TYPE_QUAL_VOLATILE);
+ gnu_type = change_qualified_type (gnu_type, TYPE_QUAL_VOLATILE);
return gnu_type;
}
if (ro_param
&& TREE_CODE (gnu_param_type) != UNCONSTRAINED_ARRAY_TYPE
&& !CONTAINS_PLACEHOLDER_P (TYPE_SIZE (gnu_param_type)))
- gnu_param_type = build_qualified_type (gnu_param_type,
- (TYPE_QUALS (gnu_param_type)
- | TYPE_QUAL_CONST));
+ gnu_param_type = change_qualified_type (gnu_param_type, TYPE_QUAL_CONST);
/* For foreign conventions, pass arrays as pointers to the element type.
First check for unconstrained array and get the underlying array. */
gnu_param_type = TREE_TYPE (gnu_param_type);
if (ro_param)
- gnu_param_type = build_qualified_type (gnu_param_type,
- (TYPE_QUALS (gnu_param_type)
- | TYPE_QUAL_CONST));
+ gnu_param_type
+ = change_qualified_type (gnu_param_type, TYPE_QUAL_CONST);
gnu_param_type = build_pointer_type (gnu_param_type);
}
gnu_param_type = build_reference_type (gnu_param_type);
if (restrict_p)
gnu_param_type
- = build_qualified_type (gnu_param_type, TYPE_QUAL_RESTRICT);
+ = change_qualified_type (gnu_param_type, TYPE_QUAL_RESTRICT);
by_ref = true;
}
return gnu_param;
}
+/* Like build_qualified_type, but TYPE_QUALS is added to the existing
+ qualifiers on TYPE. */
+
+static tree
+change_qualified_type (tree type, int type_quals)
+{
+ return build_qualified_type (type, TYPE_QUALS (type) | type_quals);
+}
+
/* Return true if DISCR1 and DISCR2 represent the same discriminant. */
static bool