summaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/gcc-interface/utils.c')
-rw-r--r--gcc/ada/gcc-interface/utils.c108
1 files changed, 56 insertions, 52 deletions
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index 43a835647d2..6aa465b8de8 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -201,13 +201,13 @@ static GTY((deletable)) struct gnat_binding_level *free_binding_level;
static GTY(()) tree global_context;
/* An array of global declarations. */
-static GTY(()) VEC(tree,gc) *global_decls;
+static GTY(()) vec<tree, va_gc> *global_decls;
/* An array of builtin function declarations. */
-static GTY(()) VEC(tree,gc) *builtin_decls;
+static GTY(()) vec<tree, va_gc> *builtin_decls;
/* An array of global renaming pointers. */
-static GTY(()) VEC(tree,gc) *global_renaming_pointers;
+static GTY(()) vec<tree, va_gc> *global_renaming_pointers;
/* A chain of unused BLOCK nodes. */
static GTY((deletable)) tree free_block_chain;
@@ -576,10 +576,10 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
if (DECL_EXTERNAL (decl))
{
if (TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl))
- VEC_safe_push (tree, gc, builtin_decls, decl);
+ vec_safe_push (builtin_decls, decl);
}
else if (global_bindings_p ())
- VEC_safe_push (tree, gc, global_decls, decl);
+ vec_safe_push (global_decls, decl);
else
{
DECL_CHAIN (decl) = BLOCK_VARS (current_binding_level->block);
@@ -1953,11 +1953,11 @@ create_subprog_type (tree return_type, tree param_decl_list, tree cico_list,
/* A list of the data type nodes of the subprogram formal parameters.
This list is generated by traversing the input list of PARM_DECL
nodes. */
- VEC(tree,gc) *param_type_list = NULL;
+ vec<tree, va_gc> *param_type_list = NULL;
tree t, type;
for (t = param_decl_list; t; t = DECL_CHAIN (t))
- VEC_safe_push (tree, gc, param_type_list, TREE_TYPE (t));
+ vec_safe_push (param_type_list, TREE_TYPE (t));
type = build_function_type_vec (return_type, param_type_list);
@@ -2517,7 +2517,7 @@ void
record_global_renaming_pointer (tree decl)
{
gcc_assert (!DECL_LOOP_PARM_P (decl) && DECL_RENAMED_OBJECT (decl));
- VEC_safe_push (tree, gc, global_renaming_pointers, decl);
+ vec_safe_push (global_renaming_pointers, decl);
}
/* Invalidate the global renaming pointers. */
@@ -2528,10 +2528,13 @@ invalidate_global_renaming_pointers (void)
unsigned int i;
tree iter;
- FOR_EACH_VEC_ELT (tree, global_renaming_pointers, i, iter)
+ if (global_renaming_pointers == NULL)
+ return;
+
+ FOR_EACH_VEC_ELT (*global_renaming_pointers, i, iter)
SET_DECL_RENAMED_OBJECT (iter, NULL_TREE);
- VEC_free (tree, gc, global_renaming_pointers);
+ vec_free (global_renaming_pointers);
}
/* Return true if VALUE is a known to be a multiple of FACTOR, which must be
@@ -3091,7 +3094,7 @@ max_size (tree exp, bool max_p)
tree
build_template (tree template_type, tree array_type, tree expr)
{
- VEC(constructor_elt,gc) *template_elts = NULL;
+ vec<constructor_elt, va_gc> *template_elts = NULL;
tree bound_list = NULL_TREE;
tree field;
@@ -3755,7 +3758,7 @@ build_vms_descriptor (tree type, Mechanism_Type mech, Entity_Id gnat_entity)
tree
fill_vms_descriptor (tree gnu_type, tree gnu_expr, Node_Id gnat_actual)
{
- VEC(constructor_elt,gc) *v = NULL;
+ vec<constructor_elt, va_gc> *v = NULL;
tree field;
gnu_expr = maybe_unconstrained_array (gnu_expr);
@@ -3813,7 +3816,7 @@ convert_vms_descriptor64 (tree gnu_type, tree gnu_expr, Entity_Id gnat_subprog)
/* See the head comment of build_vms_descriptor. */
int iklass = TREE_INT_CST_LOW (DECL_INITIAL (klass));
tree lfield, ufield;
- VEC(constructor_elt,gc) *v;
+ vec<constructor_elt, va_gc> *v;
/* Convert POINTER to the pointer-to-array type. */
gnu_expr64 = convert (p_array_type, gnu_expr64);
@@ -3823,7 +3826,7 @@ convert_vms_descriptor64 (tree gnu_type, tree gnu_expr, Entity_Id gnat_subprog)
case 1: /* Class S */
case 15: /* Class SB */
/* Build {1, LENGTH} template; LENGTH64 is the 5th field. */
- v = VEC_alloc (constructor_elt, gc, 2);
+ vec_alloc (v, 2);
t = DECL_CHAIN (DECL_CHAIN (klass));
t = build3 (COMPONENT_REF, TREE_TYPE (t), desc, t, NULL_TREE);
CONSTRUCTOR_APPEND_ELT (v, min_field,
@@ -3855,7 +3858,7 @@ convert_vms_descriptor64 (tree gnu_type, tree gnu_expr, Entity_Id gnat_subprog)
(TREE_TYPE (DECL_CHAIN (TYPE_FIELDS (template_type))), ufield);
/* Build the template in the form of a constructor. */
- v = VEC_alloc (constructor_elt, gc, 2);
+ vec_alloc (v, 2);
CONSTRUCTOR_APPEND_ELT (v, TYPE_FIELDS (template_type), lfield);
CONSTRUCTOR_APPEND_ELT (v, DECL_CHAIN (TYPE_FIELDS (template_type)),
ufield);
@@ -3903,7 +3906,7 @@ convert_vms_descriptor64 (tree gnu_type, tree gnu_expr, Entity_Id gnat_subprog)
(TREE_TYPE (DECL_CHAIN (TYPE_FIELDS (template_type))), ufield);
/* Build the template in the form of a constructor. */
- v = VEC_alloc (constructor_elt, gc, 2);
+ vec_alloc (v, 2);
CONSTRUCTOR_APPEND_ELT (v, TYPE_FIELDS (template_type), lfield);
CONSTRUCTOR_APPEND_ELT (v, DECL_CHAIN (TYPE_FIELDS (template_type)),
ufield);
@@ -3924,7 +3927,7 @@ convert_vms_descriptor64 (tree gnu_type, tree gnu_expr, Entity_Id gnat_subprog)
}
/* Build the fat pointer in the form of a constructor. */
- v = VEC_alloc (constructor_elt, gc, 2);
+ vec_alloc (v, 2);
CONSTRUCTOR_APPEND_ELT (v, TYPE_FIELDS (gnu_type), gnu_expr64);
CONSTRUCTOR_APPEND_ELT (v, DECL_CHAIN (TYPE_FIELDS (gnu_type)),
template_addr);
@@ -3966,7 +3969,7 @@ convert_vms_descriptor32 (tree gnu_type, tree gnu_expr, Entity_Id gnat_subprog)
tree template_tree, template_addr, aflags, dimct, t, u;
/* See the head comment of build_vms_descriptor. */
int iklass = TREE_INT_CST_LOW (DECL_INITIAL (klass));
- VEC(constructor_elt,gc) *v;
+ vec<constructor_elt, va_gc> *v;
/* Convert POINTER to the pointer-to-array type. */
gnu_expr32 = convert (p_array_type, gnu_expr32);
@@ -3976,7 +3979,7 @@ convert_vms_descriptor32 (tree gnu_type, tree gnu_expr, Entity_Id gnat_subprog)
case 1: /* Class S */
case 15: /* Class SB */
/* Build {1, LENGTH} template; LENGTH is the 1st field. */
- v = VEC_alloc (constructor_elt, gc, 2);
+ vec_alloc (v, 2);
t = TYPE_FIELDS (desc_type);
t = build3 (COMPONENT_REF, TREE_TYPE (t), desc, t, NULL_TREE);
CONSTRUCTOR_APPEND_ELT (v, min_field,
@@ -4048,7 +4051,7 @@ convert_vms_descriptor32 (tree gnu_type, tree gnu_expr, Entity_Id gnat_subprog)
}
/* Build the fat pointer in the form of a constructor. */
- v = VEC_alloc (constructor_elt, gc, 2);
+ vec_alloc (v, 2);
CONSTRUCTOR_APPEND_ELT (v, TYPE_FIELDS (gnu_type), gnu_expr32);
CONSTRUCTOR_APPEND_ELT (v, DECL_CHAIN (TYPE_FIELDS (gnu_type)),
template_addr);
@@ -4306,7 +4309,8 @@ convert_to_fat_pointer (tree type, tree expr)
tree p_array_type = TREE_TYPE (TYPE_FIELDS (type));
tree etype = TREE_TYPE (expr);
tree template_tree;
- VEC(constructor_elt,gc) *v = VEC_alloc (constructor_elt, gc, 2);
+ vec<constructor_elt, va_gc> *v;
+ vec_alloc (v, 2);
/* If EXPR is null, make a fat pointer that contains a null pointer to the
array (compare_fat_pointers ensures that this is the full discriminant)
@@ -4323,7 +4327,8 @@ convert_to_fat_pointer (tree type, tree expr)
{
/* The template type can still be dummy at this point so we build an
empty constructor. The middle-end will fill it in with zeros. */
- t = build_constructor (template_type, NULL);
+ t = build_constructor (template_type,
+ NULL);
TREE_CONSTANT (t) = TREE_STATIC (t) = 1;
null_bounds = build_unary_op (ADDR_EXPR, NULL_TREE, t);
SET_TYPE_NULL_BOUNDS (ptr_template_type, null_bounds);
@@ -4425,7 +4430,7 @@ convert (tree type, tree expr)
constructor to build the record, unless a variable size is involved. */
else if (code == RECORD_TYPE && TYPE_PADDING_P (type))
{
- VEC(constructor_elt,gc) *v;
+ vec<constructor_elt, va_gc> *v;
/* If we previously converted from another type and our type is
of variable size, remove the conversion to avoid the need for
@@ -4478,7 +4483,7 @@ convert (tree type, tree expr)
expr),
false);
- v = VEC_alloc (constructor_elt, gc, 1);
+ vec_alloc (v, 1);
CONSTRUCTOR_APPEND_ELT (v, TYPE_FIELDS (type),
convert (TREE_TYPE (TYPE_FIELDS (type)), expr));
return gnat_build_constructor (type, v);
@@ -4495,11 +4500,9 @@ convert (tree type, tree expr)
/* If we have just converted to this padded type, just get the
inner expression. */
if (TREE_CODE (expr) == CONSTRUCTOR
- && !VEC_empty (constructor_elt, CONSTRUCTOR_ELTS (expr))
- && VEC_index (constructor_elt, CONSTRUCTOR_ELTS (expr), 0).index
- == TYPE_FIELDS (etype))
- unpadded
- = VEC_index (constructor_elt, CONSTRUCTOR_ELTS (expr), 0).value;
+ && !vec_safe_is_empty (CONSTRUCTOR_ELTS (expr))
+ && (*CONSTRUCTOR_ELTS (expr))[0].index == TYPE_FIELDS (etype))
+ unpadded = (*CONSTRUCTOR_ELTS (expr))[0].value;
/* Otherwise, build an explicit component reference. */
else
@@ -4533,7 +4536,8 @@ convert (tree type, tree expr)
if (code == RECORD_TYPE && TYPE_CONTAINS_TEMPLATE_P (type))
{
tree obj_type = TREE_TYPE (DECL_CHAIN (TYPE_FIELDS (type)));
- VEC(constructor_elt,gc) *v = VEC_alloc (constructor_elt, gc, 2);
+ vec<constructor_elt, va_gc> *v;
+ vec_alloc (v, 2);
/* If the source already has a template, get a reference to the
associated array only, as we are going to rebuild a template
@@ -4592,8 +4596,7 @@ convert (tree type, tree expr)
{
expr = copy_node (expr);
TREE_TYPE (expr) = type;
- CONSTRUCTOR_ELTS (expr)
- = VEC_copy (constructor_elt, gc, CONSTRUCTOR_ELTS (expr));
+ CONSTRUCTOR_ELTS (expr) = vec_safe_copy (CONSTRUCTOR_ELTS (expr));
return expr;
}
@@ -4606,9 +4609,10 @@ convert (tree type, tree expr)
|| tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (etype))))
{
- VEC(constructor_elt,gc) *e = CONSTRUCTOR_ELTS (expr);
- unsigned HOST_WIDE_INT len = VEC_length (constructor_elt, e);
- VEC(constructor_elt,gc) *v = VEC_alloc (constructor_elt, gc, len);
+ vec<constructor_elt, va_gc> *e = CONSTRUCTOR_ELTS (expr);
+ unsigned HOST_WIDE_INT len = vec_safe_length (e);
+ vec<constructor_elt, va_gc> *v;
+ vec_alloc (v, len);
tree efield = TYPE_FIELDS (etype), field = TYPE_FIELDS (type);
unsigned HOST_WIDE_INT idx;
tree index, value;
@@ -4626,7 +4630,7 @@ convert (tree type, tree expr)
if (!SAME_FIELD_P (efield, field))
break;
constructor_elt elt = {field, convert (TREE_TYPE (field), value)};
- VEC_quick_push (constructor_elt, v, elt);
+ v->quick_push (elt);
/* If packing has made this field a bitfield and the input
value couldn't be emitted statically any more, we need to
@@ -4663,9 +4667,9 @@ convert (tree type, tree expr)
&& gnat_types_compatible_p (TYPE_REPRESENTATIVE_ARRAY (type),
etype))
{
- VEC(constructor_elt,gc) *e = CONSTRUCTOR_ELTS (expr);
- unsigned HOST_WIDE_INT len = VEC_length (constructor_elt, e);
- VEC(constructor_elt,gc) *v;
+ vec<constructor_elt, va_gc> *e = CONSTRUCTOR_ELTS (expr);
+ unsigned HOST_WIDE_INT len = vec_safe_length (e);
+ vec<constructor_elt, va_gc> *v;
unsigned HOST_WIDE_INT ix;
tree value;
@@ -4689,11 +4693,11 @@ convert (tree type, tree expr)
}
/* Otherwise, build a regular vector constructor. */
- v = VEC_alloc (constructor_elt, gc, len);
+ vec_alloc (v, len);
FOR_EACH_CONSTRUCTOR_VALUE (e, ix, value)
{
constructor_elt elt = {NULL_TREE, value};
- VEC_quick_push (constructor_elt, v, elt);
+ v->quick_push (elt);
}
expr = copy_node (expr);
TREE_TYPE (expr) = type;
@@ -4880,7 +4884,8 @@ convert (tree type, tree expr)
case RECORD_TYPE:
if (TYPE_JUSTIFIED_MODULAR_P (type) && !AGGREGATE_TYPE_P (etype))
{
- VEC(constructor_elt,gc) *v = VEC_alloc (constructor_elt, gc, 1);
+ vec<constructor_elt, va_gc> *v;
+ vec_alloc (v, 1);
CONSTRUCTOR_APPEND_ELT (v, TYPE_FIELDS (type),
convert (TREE_TYPE (TYPE_FIELDS (type)),
@@ -5048,9 +5053,7 @@ remove_conversions (tree exp, bool true_address)
&& TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
&& TYPE_JUSTIFIED_MODULAR_P (TREE_TYPE (exp)))
return
- remove_conversions (VEC_index (constructor_elt,
- CONSTRUCTOR_ELTS (exp), 0).value,
- true);
+ remove_conversions ((*CONSTRUCTOR_ELTS (exp))[0].value, true);
break;
case COMPONENT_REF:
@@ -5292,7 +5295,8 @@ unchecked_convert (tree type, tree expr, bool notrunc_p)
{
tree rec_type = make_node (RECORD_TYPE);
unsigned HOST_WIDE_INT prec = TREE_INT_CST_LOW (TYPE_RM_SIZE (etype));
- VEC(constructor_elt,gc) *v = VEC_alloc (constructor_elt, gc, 1);
+ vec<constructor_elt, va_gc> *v;
+ vec_alloc (v, 1);
tree field_type, field;
if (TYPE_UNSIGNED (etype))
@@ -5575,7 +5579,7 @@ gnat_write_global_declarations (void)
/* If we have declared types as used at the global level, insert them in
the global hash table. We use a dummy variable for this purpose. */
- if (!VEC_empty (tree, types_used_by_cur_var_decl))
+ if (types_used_by_cur_var_decl && !types_used_by_cur_var_decl->is_empty ())
{
struct varpool_node *node;
char *label;
@@ -5589,9 +5593,9 @@ gnat_write_global_declarations (void)
node = varpool_node_for_decl (dummy_global);
node->symbol.force_output = 1;
- while (!VEC_empty (tree, types_used_by_cur_var_decl))
+ while (!types_used_by_cur_var_decl->is_empty ())
{
- tree t = VEC_pop (tree, types_used_by_cur_var_decl);
+ tree t = types_used_by_cur_var_decl->pop ();
types_used_by_var_decl_insert (t, dummy_global);
}
}
@@ -5600,7 +5604,7 @@ gnat_write_global_declarations (void)
ensures that global types whose compilation hasn't been finalized yet,
for example pointers to Taft amendment types, have their compilation
finalized in the right context. */
- FOR_EACH_VEC_ELT (tree, global_decls, i, iter)
+ FOR_EACH_VEC_SAFE_ELT (global_decls, i, iter)
if (TREE_CODE (iter) == TYPE_DECL)
debug_hooks->global_decl (iter);
@@ -5612,7 +5616,7 @@ gnat_write_global_declarations (void)
if (!seen_error ())
{
timevar_push (TV_SYMOUT);
- FOR_EACH_VEC_ELT (tree, global_decls, i, iter)
+ FOR_EACH_VEC_SAFE_ELT (global_decls, i, iter)
if (TREE_CODE (iter) != TYPE_DECL)
debug_hooks->global_decl (iter);
timevar_pop (TV_SYMOUT);
@@ -5641,7 +5645,7 @@ builtin_decl_for (tree name)
unsigned i;
tree decl;
- FOR_EACH_VEC_ELT (tree, builtin_decls, i, decl)
+ FOR_EACH_VEC_SAFE_ELT (builtin_decls, i, decl)
if (DECL_NAME (decl) == name)
return decl;