diff options
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 30 | ||||
-rw-r--r-- | gcc/cp/Make-lang.in | 2 | ||||
-rw-r--r-- | gcc/cp/call.c | 218 | ||||
-rw-r--r-- | gcc/cp/class.c | 173 | ||||
-rw-r--r-- | gcc/cp/cp-gimplify.c | 17 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 91 | ||||
-rw-r--r-- | gcc/cp/cvt.c | 4 | ||||
-rw-r--r-- | gcc/cp/decl.c | 126 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 74 | ||||
-rw-r--r-- | gcc/cp/error.c | 26 | ||||
-rw-r--r-- | gcc/cp/except.c | 10 | ||||
-rw-r--r-- | gcc/cp/init.c | 91 | ||||
-rw-r--r-- | gcc/cp/mangle.c | 28 | ||||
-rw-r--r-- | gcc/cp/method.c | 16 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 186 | ||||
-rw-r--r-- | gcc/cp/name-lookup.h | 18 | ||||
-rw-r--r-- | gcc/cp/parser.c | 246 | ||||
-rw-r--r-- | gcc/cp/parser.h | 29 | ||||
-rw-r--r-- | gcc/cp/pt.c | 99 | ||||
-rw-r--r-- | gcc/cp/repo.c | 6 | ||||
-rw-r--r-- | gcc/cp/rtti.c | 79 | ||||
-rw-r--r-- | gcc/cp/search.c | 43 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 226 | ||||
-rw-r--r-- | gcc/cp/tree.c | 40 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 57 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 44 |
26 files changed, 959 insertions, 1020 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1a71dc9..110cdc4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,33 @@ +2012-11-17 Diego Novillo <dnovillo@google.com> + + Adjust for new vec API (http://gcc.gnu.org/wiki/cxx-conversion/cxx-vec) + + * Make-lang.in: Remove dependencies on vecir.h and vecprim.h everywhere. + * call.c: Use new vec API in vec.h. + * class.c: Likewise. + * cp-gimplify.c: Likewise. + * cp-tree.h: Likewise. + * cvt.c: Likewise. + * decl.c: Likewise. + * decl2.c: Likewise. + * error.c: Likewise. + * except.c: Likewise. + * init.c: Likewise. + * mangle.c: Likewise. + * method.c: Likewise. + * name-lookup.c: Likewise. + * name-lookup.h: Likewise. + * parser.c: Likewise. + * parser.h: Likewise. + * pt.c: Likewise. + * repo.c: Likewise. + * rtti.c: Likewise. + * search.c: Likewise. + * semantics.c: Likewise. + * tree.c: Likewise. + * typeck.c: Likewise. + * typeck2.c: Likewise. + 2012-11-17 Gabriel Dos Reis <gdr@integrable-solutions.net> * semantics.c (finish_id_expression): Tidy diagnostic message. diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in index 812f3cb5..9d92f64 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in @@ -317,7 +317,7 @@ cp/except.o: cp/except.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) \ cp/cfns.h $(TREE_INLINE_H) $(TARGET_H) gt-cp-except.h cp/expr.o: cp/expr.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) $(TM_P_H) cp/pt.o: cp/pt.c $(CXX_TREE_H) $(TM_H) cp/decl.h cp/cp-objcp-common.h \ - toplev.h $(TREE_INLINE_H) pointer-set.h gt-cp-pt.h vecprim.h intl.h \ + toplev.h $(TREE_INLINE_H) pointer-set.h gt-cp-pt.h intl.h \ c-family/c-objc.h cp/error.o: cp/error.c $(CXX_TREE_H) $(TM_H) $(DIAGNOSTIC_H) \ $(FLAGS_H) $(REAL_H) $(LANGHOOKS_DEF_H) $(CXX_PRETTY_PRINT_H) \ diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 77bd288..35a3f91 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -169,14 +169,14 @@ static tree build_this (tree); static struct z_candidate *splice_viable (struct z_candidate *, bool, bool *); static bool any_strictly_viable (struct z_candidate *); static struct z_candidate *add_template_candidate - (struct z_candidate **, tree, tree, tree, tree, const VEC(tree,gc) *, + (struct z_candidate **, tree, tree, tree, tree, const vec<tree, va_gc> *, tree, tree, tree, int, unification_kind_t, tsubst_flags_t); static struct z_candidate *add_template_candidate_real - (struct z_candidate **, tree, tree, tree, tree, const VEC(tree,gc) *, + (struct z_candidate **, tree, tree, tree, tree, const vec<tree, va_gc> *, tree, tree, tree, int, tree, unification_kind_t, tsubst_flags_t); static struct z_candidate *add_template_conv_candidate - (struct z_candidate **, tree, tree, tree, const VEC(tree,gc) *, tree, - tree, tree, tsubst_flags_t); + (struct z_candidate **, tree, tree, tree, const vec<tree, va_gc> *, + tree, tree, tree, tsubst_flags_t); static void add_builtin_candidates (struct z_candidate **, enum tree_code, enum tree_code, tree, tree *, int, tsubst_flags_t); @@ -188,10 +188,10 @@ static void build_builtin_candidate (struct z_candidate **, tree, tree, tree, tree *, tree *, int, tsubst_flags_t); static struct z_candidate *add_conv_candidate - (struct z_candidate **, tree, tree, tree, const VEC(tree,gc) *, tree, + (struct z_candidate **, tree, tree, tree, const vec<tree, va_gc> *, tree, tree, tsubst_flags_t); static struct z_candidate *add_function_candidate - (struct z_candidate **, tree, tree, tree, const VEC(tree,gc) *, tree, + (struct z_candidate **, tree, tree, tree, const vec<tree, va_gc> *, tree, tree, int, tsubst_flags_t); static conversion *implicit_conversion (tree, tree, tree, bool, int, tsubst_flags_t); @@ -205,7 +205,7 @@ static bool is_subseq (conversion *, conversion *); static conversion *maybe_handle_ref_bind (conversion **); static void maybe_handle_implicit_object (conversion **); static struct z_candidate *add_candidate - (struct z_candidate **, tree, tree, const VEC(tree,gc) *, size_t, + (struct z_candidate **, tree, tree, const vec<tree, va_gc> *, size_t, conversion **, tree, tree, int, struct rejection_reason *); static tree source_type (conversion *); static void add_warning (struct z_candidate *, struct z_candidate *); @@ -215,8 +215,8 @@ static bool promoted_arithmetic_type_p (tree); static conversion *conditional_conversion (tree, tree, tsubst_flags_t); static char *name_as_c_string (tree, tree, bool *); static tree prep_operand (tree); -static void add_candidates (tree, tree, const VEC(tree,gc) *, tree, tree, bool, - tree, tree, int, struct z_candidate **, +static void add_candidates (tree, tree, const vec<tree, va_gc> *, tree, tree, + bool, tree, tree, int, struct z_candidate **, tsubst_flags_t); static conversion *merge_conversion_sequences (conversion *, conversion *); static bool magic_varargs_p (tree); @@ -511,7 +511,7 @@ struct z_candidate { /* The rest of the arguments to use when calling this function. If there are no further arguments this may be NULL or it may be an empty vector. */ - const VEC(tree,gc) *args; + const vec<tree, va_gc> *args; /* The implicit conversion sequences for each of the arguments to FN. */ conversion **convs; @@ -1772,7 +1772,7 @@ implicit_conversion (tree to, tree from, tree expr, bool c_cast_p, static struct z_candidate * add_candidate (struct z_candidate **candidates, - tree fn, tree first_arg, const VEC(tree,gc) *args, + tree fn, tree first_arg, const vec<tree, va_gc> *args, size_t num_convs, conversion **convs, tree access_path, tree conversion_path, int viable, struct rejection_reason *reason) @@ -1822,7 +1822,7 @@ remaining_arguments (tree arg) static struct z_candidate * add_function_candidate (struct z_candidate **candidates, tree fn, tree ctype, tree first_arg, - const VEC(tree,gc) *args, tree access_path, + const vec<tree, va_gc> *args, tree access_path, tree conversion_path, int flags, tsubst_flags_t complain) { @@ -1855,7 +1855,7 @@ add_function_candidate (struct z_candidate **candidates, else skip = 0; - len = VEC_length (tree, args) - skip + (first_arg != NULL_TREE ? 1 : 0); + len = vec_safe_length (args) - skip + (first_arg != NULL_TREE ? 1 : 0); convs = alloc_conversions (len); /* 13.3.2 - Viable functions [over.match.viable] @@ -1927,8 +1927,7 @@ add_function_candidate (struct z_candidate **candidates, arg = first_arg; else arg = CONST_CAST_TREE ( - VEC_index (tree, args, - i + skip - (first_arg != NULL_TREE ? 1 : 0))); + (*args)[i + skip - (first_arg != NULL_TREE ? 1 : 0)]); argtype = lvalue_type (arg); is_this = (i == 0 && DECL_NONSTATIC_MEMBER_FUNCTION_P (fn) @@ -2032,7 +2031,7 @@ add_function_candidate (struct z_candidate **candidates, static struct z_candidate * add_conv_candidate (struct z_candidate **candidates, tree fn, tree obj, - tree first_arg, const VEC(tree,gc) *arglist, + tree first_arg, const vec<tree, va_gc> *arglist, tree access_path, tree conversion_path, tsubst_flags_t complain) { @@ -2046,7 +2045,7 @@ add_conv_candidate (struct z_candidate **candidates, tree fn, tree obj, parmlist = TREE_TYPE (parmlist); parmlist = TYPE_ARG_TYPES (parmlist); - len = VEC_length (tree, arglist) + (first_arg != NULL_TREE ? 1 : 0) + 1; + len = vec_safe_length (arglist) + (first_arg != NULL_TREE ? 1 : 0) + 1; convs = alloc_conversions (len); parmnode = parmlist; viable = 1; @@ -2067,8 +2066,7 @@ add_conv_candidate (struct z_candidate **candidates, tree fn, tree obj, else if (i == 1 && first_arg != NULL_TREE) arg = first_arg; else - arg = VEC_index (tree, arglist, - i - (first_arg != NULL_TREE ? 1 : 0) - 1); + arg = (*arglist)[i - (first_arg != NULL_TREE ? 1 : 0) - 1]; argtype = lvalue_type (arg); if (i == 0) @@ -2676,7 +2674,7 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code, tree type, argtypes[3], t; /* TYPES[i] is the set of possible builtin-operator parameter types we will consider for the Ith argument. */ - VEC(tree,gc) *types[2]; + vec<tree, va_gc> *types[2]; unsigned ix; for (i = 0; i < 3; ++i) @@ -2758,11 +2756,9 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code, if (code == COND_EXPR) { if (real_lvalue_p (args[i])) - VEC_safe_push (tree, gc, types[i], - build_reference_type (argtypes[i])); + vec_safe_push (types[i], build_reference_type (argtypes[i])); - VEC_safe_push (tree, gc, types[i], - TYPE_MAIN_VARIANT (argtypes[i])); + vec_safe_push (types[i], TYPE_MAIN_VARIANT (argtypes[i])); } else if (! convs) @@ -2778,49 +2774,48 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code, continue; if (code == COND_EXPR && TREE_CODE (type) == REFERENCE_TYPE) - VEC_safe_push (tree, gc, types[i], type); + vec_safe_push (types[i], type); type = non_reference (type); if (i != 0 || ! ref1) { type = cv_unqualified (type_decays_to (type)); if (enum_p && TREE_CODE (type) == ENUMERAL_TYPE) - VEC_safe_push (tree, gc, types[i], type); + vec_safe_push (types[i], type); if (INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (type)) type = type_promotes_to (type); } if (! vec_member (type, types[i])) - VEC_safe_push (tree, gc, types[i], type); + vec_safe_push (types[i], type); } } else { if (code == COND_EXPR && real_lvalue_p (args[i])) - VEC_safe_push (tree, gc, types[i], - build_reference_type (argtypes[i])); + vec_safe_push (types[i], build_reference_type (argtypes[i])); type = non_reference (argtypes[i]); if (i != 0 || ! ref1) { type = cv_unqualified (type_decays_to (type)); if (enum_p && UNSCOPED_ENUM_P (type)) - VEC_safe_push (tree, gc, types[i], type); + vec_safe_push (types[i], type); if (INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (type)) type = type_promotes_to (type); } - VEC_safe_push (tree, gc, types[i], type); + vec_safe_push (types[i], type); } } /* Run through the possible parameter types of both arguments, creating candidates with those parameter types. */ - FOR_EACH_VEC_ELT_REVERSE (tree, types[0], ix, t) + FOR_EACH_VEC_ELT_REVERSE (*(types[0]), ix, t) { unsigned jx; tree u; - if (!VEC_empty (tree, types[1])) - FOR_EACH_VEC_ELT_REVERSE (tree, types[1], jx, u) + if (!types[1]->is_empty ()) + FOR_EACH_VEC_ELT_REVERSE (*(types[1]), jx, u) add_builtin_candidate (candidates, code, code2, fnname, t, u, args, argtypes, flags, complain); @@ -2848,14 +2843,14 @@ add_builtin_candidates (struct z_candidate **candidates, enum tree_code code, static struct z_candidate* add_template_candidate_real (struct z_candidate **candidates, tree tmpl, tree ctype, tree explicit_targs, tree first_arg, - const VEC(tree,gc) *arglist, tree return_type, + const vec<tree, va_gc> *arglist, tree return_type, tree access_path, tree conversion_path, int flags, tree obj, unification_kind_t strict, tsubst_flags_t complain) { int ntparms = DECL_NTPARMS (tmpl); tree targs = make_tree_vec (ntparms); - unsigned int len = VEC_length (tree, arglist); + unsigned int len = vec_safe_length (arglist); unsigned int nargs = (first_arg == NULL_TREE ? 0 : 1) + len; unsigned int skip_without_in_chrg = 0; tree first_arg_without_in_chrg = first_arg; @@ -2901,7 +2896,7 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl, ++ia; } for (ix = skip_without_in_chrg; - VEC_iterate (tree, arglist, ix, arg); + vec_safe_iterate (arglist, ix, &arg); ++ix) { args_without_in_chrg[ia] = arg; @@ -3002,7 +2997,7 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl, static struct z_candidate * add_template_candidate (struct z_candidate **candidates, tree tmpl, tree ctype, tree explicit_targs, tree first_arg, - const VEC(tree,gc) *arglist, tree return_type, + const vec<tree, va_gc> *arglist, tree return_type, tree access_path, tree conversion_path, int flags, unification_kind_t strict, tsubst_flags_t complain) { @@ -3017,7 +3012,7 @@ add_template_candidate (struct z_candidate **candidates, tree tmpl, tree ctype, static struct z_candidate * add_template_conv_candidate (struct z_candidate **candidates, tree tmpl, tree obj, tree first_arg, - const VEC(tree,gc) *arglist, + const vec<tree, va_gc> *arglist, tree return_type, tree access_path, tree conversion_path, tsubst_flags_t complain) { @@ -3336,7 +3331,7 @@ merge_conversion_sequences (conversion *user_seq, conversion *std_seq) non-list constructor. Parameters are as for add_candidates, except that the arguments are in - the form of a CONSTRUCTOR (the initializer list) rather than a VEC, and + the form of a CONSTRUCTOR (the initializer list) rather than a vector, and the RETURN_TYPE parameter is replaced by TOTYPE, the desired type. */ static void @@ -3348,7 +3343,7 @@ add_list_candidates (tree fns, tree first_arg, struct z_candidate **candidates, tsubst_flags_t complain) { - VEC(tree,gc) *args; + vec<tree, va_gc> *args; gcc_assert (*candidates == NULL); @@ -3403,7 +3398,7 @@ build_user_type_conversion_1 (tree totype, tree expr, int flags, tree conv_fns = NULL_TREE; conversion *conv = NULL; tree first_arg = NULL_TREE; - VEC(tree,gc) *args = NULL; + vec<tree, va_gc> *args = NULL; bool any_viable_p; int convflags; @@ -3734,13 +3729,13 @@ build_integral_nontype_arg_conv (tree type, tree expr, tsubst_flags_t complain) /* Do any initial processing on the arguments to a function call. */ -static VEC(tree,gc) * -resolve_args (VEC(tree,gc) *args, tsubst_flags_t complain) +static vec<tree, va_gc> * +resolve_args (vec<tree, va_gc> *args, tsubst_flags_t complain) { unsigned int ix; tree arg; - FOR_EACH_VEC_ELT (tree, args, ix, arg) + FOR_EACH_VEC_SAFE_ELT (args, ix, arg) { if (error_operand_p (arg)) return NULL; @@ -3770,7 +3765,7 @@ resolve_args (VEC(tree,gc) *args, tsubst_flags_t complain) static struct z_candidate * perform_overload_resolution (tree fn, - const VEC(tree,gc) *args, + const vec<tree, va_gc> *args, struct z_candidate **candidates, bool *any_viable_p, tsubst_flags_t complain) { @@ -3823,7 +3818,7 @@ perform_overload_resolution (tree fn, functions. */ static void -print_error_for_call_failure (tree fn, VEC(tree,gc) *args, bool any_viable_p, +print_error_for_call_failure (tree fn, vec<tree, va_gc> *args, bool any_viable_p, struct z_candidate *candidates) { tree name = DECL_NAME (OVL_CURRENT (fn)); @@ -3844,7 +3839,7 @@ print_error_for_call_failure (tree fn, VEC(tree,gc) *args, bool any_viable_p, ARGS. */ tree -build_new_function_call (tree fn, VEC(tree,gc) **args, bool koenig_p, +build_new_function_call (tree fn, vec<tree, va_gc> **args, bool koenig_p, tsubst_flags_t complain) { struct z_candidate *candidates, *cand; @@ -3929,7 +3924,7 @@ build_new_function_call (tree fn, VEC(tree,gc) **args, bool koenig_p, function called. */ tree -build_operator_new_call (tree fnname, VEC(tree,gc) **args, +build_operator_new_call (tree fnname, vec<tree, va_gc> **args, tree *size, tree *cookie_size, tree size_check, tree *fn, tsubst_flags_t complain) { @@ -3945,7 +3940,7 @@ build_operator_new_call (tree fnname, VEC(tree,gc) **args, if (size_check != NULL_TREE) *size = fold_build3 (COND_EXPR, sizetype, size_check, original_size, TYPE_MAX_VALUE (sizetype)); - VEC_safe_insert (tree, gc, *args, 0, *size); + vec_safe_insert (*args, 0, *size); *args = resolve_args (*args, complain); if (*args == NULL) return error_mark_node; @@ -3985,9 +3980,8 @@ build_operator_new_call (tree fnname, VEC(tree,gc) **args, /* In G++ 3.2, the check was implemented incorrectly; it looked at the placement expression, rather than the type of the function. */ - if (VEC_length (tree, *args) == 2 - && same_type_p (TREE_TYPE (VEC_index (tree, *args, 1)), - ptr_type_node)) + if ((*args)->length () == 2 + && same_type_p (TREE_TYPE ((**args)[1]), ptr_type_node)) use_cookie = false; } else @@ -4014,7 +4008,7 @@ build_operator_new_call (tree fnname, VEC(tree,gc) **args, *size = fold_build3 (COND_EXPR, sizetype, size_check, *size, TYPE_MAX_VALUE (sizetype)); /* Update the argument list to reflect the adjusted size. */ - VEC_replace (tree, *args, 0, *size); + (**args)[0] = *size; } else *cookie_size = NULL_TREE; @@ -4031,7 +4025,7 @@ build_operator_new_call (tree fnname, VEC(tree,gc) **args, /* Build a new call to operator(). This may change ARGS. */ static tree -build_op_call_1 (tree obj, VEC(tree,gc) **args, tsubst_flags_t complain) +build_op_call_1 (tree obj, vec<tree, va_gc> **args, tsubst_flags_t complain) { struct z_candidate *candidates = 0, *cand; tree fns, convs, first_mem_arg = NULL_TREE; @@ -4165,7 +4159,7 @@ build_op_call_1 (tree obj, VEC(tree,gc) **args, tsubst_flags_t complain) /* Wrapper for above. */ tree -build_op_call (tree obj, VEC(tree,gc) **args, tsubst_flags_t complain) +build_op_call (tree obj, vec<tree, va_gc> **args, tsubst_flags_t complain) { tree ret; bool subtime = timevar_cond_start (TV_OVERLOAD); @@ -4899,7 +4893,7 @@ prep_operand (tree operand) add_function_candidate. */ static void -add_candidates (tree fns, tree first_arg, const VEC(tree,gc) *args, +add_candidates (tree fns, tree first_arg, const vec<tree, va_gc> *args, tree return_type, tree explicit_targs, bool template_only, tree conversion_path, tree access_path, @@ -4908,7 +4902,7 @@ add_candidates (tree fns, tree first_arg, const VEC(tree,gc) *args, tsubst_flags_t complain) { tree ctype; - const VEC(tree,gc) *non_static_args; + const vec<tree, va_gc> *non_static_args; bool check_list_ctor; bool check_converting; unification_kind_t strict; @@ -4964,7 +4958,7 @@ add_candidates (tree fns, tree first_arg, const VEC(tree,gc) *args, for (; fns; fns = OVL_NEXT (fns)) { tree fn_first_arg; - const VEC(tree,gc) *fn_args; + const vec<tree, va_gc> *fn_args; fn = OVL_CURRENT (fns); @@ -4982,12 +4976,12 @@ add_candidates (tree fns, tree first_arg, const VEC(tree,gc) *args, { unsigned int ix; tree arg; - VEC(tree,gc) *tempvec - = VEC_alloc (tree, gc, VEC_length (tree, args) - 1); - for (ix = 1; VEC_iterate (tree, args, ix, arg); ++ix) - VEC_quick_push (tree, tempvec, arg); + vec<tree, va_gc> *tempvec; + vec_alloc (tempvec, args->length () - 1); + for (ix = 1; args->iterate (ix, &arg); ++ix) + tempvec->quick_push (arg); non_static_args = tempvec; - first_arg = build_this (VEC_index (tree, args, 0)); + first_arg = build_this ((*args)[0]); } fn_first_arg = first_arg; @@ -5031,7 +5025,7 @@ build_new_op_1 (location_t loc, enum tree_code code, int flags, tree arg1, tree arg2, tree arg3, tree *overload, tsubst_flags_t complain) { struct z_candidate *candidates = 0, *cand; - VEC(tree,gc) *arglist; + vec<tree, va_gc> *arglist; tree fnname; tree args[3]; tree result = NULL_TREE; @@ -5098,12 +5092,12 @@ build_new_op_1 (location_t loc, enum tree_code code, int flags, tree arg1, if (code == POSTINCREMENT_EXPR || code == POSTDECREMENT_EXPR) arg2 = integer_zero_node; - arglist = VEC_alloc (tree, gc, 3); - VEC_quick_push (tree, arglist, arg1); + vec_alloc (arglist, 3); + arglist->quick_push (arg1); if (arg2 != NULL_TREE) - VEC_quick_push (tree, arglist, arg2); + arglist->quick_push (arg2); if (arg3 != NULL_TREE) - VEC_quick_push (tree, arglist, arg3); + arglist->quick_push (arg3); /* Get the high-water mark for the CONVERSION_OBSTACK. */ p = conversion_obstack_alloc (0); @@ -5645,12 +5639,13 @@ build_op_delete_call (enum tree_code code, tree addr, tree size, else { tree ret; - VEC(tree,gc) *args = VEC_alloc (tree, gc, 2); - VEC_quick_push (tree, args, addr); + vec<tree, va_gc> *args; + vec_alloc (args, 2); + args->quick_push (addr); if (FUNCTION_ARG_CHAIN (fn) != void_list_node) - VEC_quick_push (tree, args, size); + args->quick_push (size); ret = cp_build_function_call_vec (fn, &args, complain); - VEC_free (tree, gc, args); + vec_free (args); return ret; } } @@ -5715,7 +5710,7 @@ build_temp (tree expr, tree type, int flags, diagnostic_t *diagnostic_kind, tsubst_flags_t complain) { int savew, savee; - VEC(tree,gc) *args; + vec<tree, va_gc> *args; savew = warningcount, savee = errorcount; args = make_tree_vector_single (expr); @@ -5965,7 +5960,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, tree new_ctor = build_constructor (init_list_type_node, NULL); unsigned len = CONSTRUCTOR_NELTS (expr); tree array, val, field; - VEC(constructor_elt,gc) *vec = NULL; + vec<constructor_elt, va_gc> *vec = NULL; unsigned ix; /* Convert all the elements. */ @@ -6340,13 +6335,14 @@ cxx_type_promotes_to (tree type) zero-based argument number. Do any required conversions. Return the converted value. */ -static GTY(()) VEC(tree,gc) *default_arg_context; +static GTY(()) vec<tree, va_gc> *default_arg_context; void push_defarg_context (tree fn) -{ VEC_safe_push (tree, gc, default_arg_context, fn); } +{ vec_safe_push (default_arg_context, fn); } + void pop_defarg_context (void) -{ VEC_pop (tree, default_arg_context); } +{ default_arg_context->pop (); } tree convert_default_arg (tree type, tree arg, tree fn, int parmnum, @@ -6359,7 +6355,7 @@ convert_default_arg (tree type, tree arg, tree fn, int parmnum, fn = DECL_ORIGIN (fn); /* Detect recursion. */ - FOR_EACH_VEC_ELT (tree, default_arg_context, i, t) + FOR_EACH_VEC_SAFE_ELT (default_arg_context, i, t) if (t == fn) { if (complain & tf_error) @@ -6581,7 +6577,7 @@ static tree build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) { tree fn = cand->fn; - const VEC(tree,gc) *args = cand->args; + const vec<tree, va_gc> *args = cand->args; tree first_arg = cand->first_arg; conversion **convs = cand->convs; conversion *conv; @@ -6608,9 +6604,9 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) unsigned int nargs; return_type = TREE_TYPE (TREE_TYPE (fn)); - nargs = VEC_length (tree, args); + nargs = vec_safe_length (args); if (first_arg == NULL_TREE) - argarray = VEC_address (tree, CONST_CAST (VEC(tree,gc) *, args)); + argarray = args->address (); else { tree *alcarray; @@ -6620,7 +6616,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) ++nargs; alcarray = XALLOCAVEC (tree, nargs); alcarray[0] = first_arg; - FOR_EACH_VEC_ELT (tree, args, ix, arg) + FOR_EACH_VEC_SAFE_ELT (args, ix, arg) alcarray[ix + 1] = arg; argarray = alcarray; } @@ -6705,7 +6701,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) /* Find maximum size of vector to hold converted arguments. */ parmlen = list_length (parm); - nargs = VEC_length (tree, args) + (first_arg != NULL_TREE ? 1 : 0); + nargs = vec_safe_length (args) + (first_arg != NULL_TREE ? 1 : 0); if (parmlen > nargs) nargs = parmlen; argarray = XALLOCAVEC (tree, nargs); @@ -6721,7 +6717,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) } else { - argarray[j++] = VEC_index (tree, args, arg_index); + argarray[j++] = (*args)[arg_index]; ++arg_index; } parm = TREE_CHAIN (parm); @@ -6730,7 +6726,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) if (DECL_HAS_VTT_PARM_P (fn)) { - argarray[j++] = VEC_index (tree, args, arg_index); + argarray[j++] = (*args)[arg_index]; ++arg_index; parm = TREE_CHAIN (parm); } @@ -6741,7 +6737,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) tree parmtype = TREE_VALUE (parm); tree arg = (first_arg != NULL_TREE ? first_arg - : VEC_index (tree, args, arg_index)); + : (*args)[arg_index]); tree argtype = TREE_TYPE (arg); tree converted_arg; tree base_binfo; @@ -6800,11 +6796,11 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) } gcc_assert (first_arg == NULL_TREE); - for (; arg_index < VEC_length (tree, args) && parm; + for (; arg_index < vec_safe_length (args) && parm; parm = TREE_CHAIN (parm), ++arg_index, ++i) { tree type = TREE_VALUE (parm); - tree arg = VEC_index (tree, args, arg_index); + tree arg = (*args)[arg_index]; bool conversion_warning = true; conv = convs[i]; @@ -6889,9 +6885,9 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) } /* Ellipsis */ - for (; arg_index < VEC_length (tree, args); ++arg_index) + for (; arg_index < vec_safe_length (args); ++arg_index) { - tree a = VEC_index (tree, args, arg_index); + tree a = (*args)[arg_index]; if (magic_varargs_p (fn)) /* Do no conversions for magic varargs. */ a = mark_type_use (a); @@ -7221,13 +7217,13 @@ in_charge_arg_for_name (tree name) store the newly constructed object into a VAR_DECL. */ tree -build_special_member_call (tree instance, tree name, VEC(tree,gc) **args, +build_special_member_call (tree instance, tree name, vec<tree, va_gc> **args, tree binfo, int flags, tsubst_flags_t complain) { tree fns; /* The type of the subobject to be constructed or destroyed. */ tree class_type; - VEC(tree,gc) *allocated = NULL; + vec<tree, va_gc> *allocated = NULL; tree ret; gcc_assert (name == complete_ctor_identifier @@ -7260,7 +7256,7 @@ build_special_member_call (tree instance, tree name, VEC(tree,gc) **args, if (name == complete_dtor_identifier || name == base_dtor_identifier || name == deleting_dtor_identifier) - gcc_assert (args == NULL || VEC_empty (tree, *args)); + gcc_assert (args == NULL || vec_safe_is_empty (*args)); /* Convert to the base class, if necessary. */ if (!same_type_ignoring_top_level_qualifiers_p @@ -7318,7 +7314,7 @@ build_special_member_call (tree instance, tree name, VEC(tree,gc) **args, args = &allocated; } - VEC_safe_insert (tree, gc, *args, 0, sub_vtt); + vec_safe_insert (*args, 0, sub_vtt); } ret = build_new_method_call (instance, fns, args, @@ -7382,7 +7378,7 @@ name_as_c_string (tree name, tree type, bool *free_p) This may change ARGS. */ static tree -build_new_method_call_1 (tree instance, tree fns, VEC(tree,gc) **args, +build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args, tree conversion_path, int flags, tree *fn_p, tsubst_flags_t complain) { @@ -7395,14 +7391,14 @@ build_new_method_call_1 (tree instance, tree fns, VEC(tree,gc) **args, tree instance_ptr; tree name; bool skip_first_for_error; - VEC(tree,gc) *user_args; + vec<tree, va_gc> *user_args; tree call; tree fn; int template_only = 0; bool any_viable_p; tree orig_instance; tree orig_fns; - VEC(tree,gc) *orig_args = NULL; + vec<tree, va_gc> *orig_args = NULL; void *p; gcc_assert (instance != NULL_TREE); @@ -7522,14 +7518,14 @@ build_new_method_call_1 (tree instance, tree fns, VEC(tree,gc) **args, /* If CONSTRUCTOR_IS_DIRECT_INIT is set, this was a T{ } form initializer, not T({ }). */ - if (DECL_CONSTRUCTOR_P (fn) && args != NULL && !VEC_empty (tree, *args) - && BRACE_ENCLOSED_INITIALIZER_P (VEC_index (tree, *args, 0)) - && CONSTRUCTOR_IS_DIRECT_INIT (VEC_index (tree, *args, 0))) + if (DECL_CONSTRUCTOR_P (fn) && args != NULL && !vec_safe_is_empty (*args) + && BRACE_ENCLOSED_INITIALIZER_P ((**args)[0]) + && CONSTRUCTOR_IS_DIRECT_INIT ((**args)[0])) { - tree init_list = VEC_index (tree, *args, 0); + tree init_list = (**args)[0]; tree init = NULL_TREE; - gcc_assert (VEC_length (tree, *args) == 1 + gcc_assert ((*args)->length () == 1 && !(flags & LOOKUP_ONLYCONVERTING)); /* If the initializer list has no elements and T is a class type with @@ -7732,7 +7728,7 @@ build_new_method_call_1 (tree instance, tree fns, VEC(tree,gc) **args, /* Wrapper for above. */ tree -build_new_method_call (tree instance, tree fns, VEC(tree,gc) **args, +build_new_method_call (tree instance, tree fns, vec<tree, va_gc> **args, tree conversion_path, int flags, tree *fn_p, tsubst_flags_t complain) { @@ -8896,7 +8892,7 @@ perform_direct_initialization_if_possible (tree type, ill-formed. */ if (CLASS_TYPE_P (type)) { - VEC(tree,gc) *args = make_tree_vector_single (expr); + vec<tree, va_gc> *args = make_tree_vector_single (expr); expr = build_special_member_call (NULL_TREE, complete_ctor_identifier, &args, type, LOOKUP_NORMAL, complain); release_tree_vector (args); @@ -9003,7 +8999,7 @@ make_temporary_var_for_ref_to_temp (tree decl, tree type) code to initialize the new variable is returned through INITP. */ static tree -set_up_extended_ref_temp (tree decl, tree expr, VEC(tree,gc) **cleanups, +set_up_extended_ref_temp (tree decl, tree expr, vec<tree, va_gc> **cleanups, tree *initp) { tree init; @@ -9076,7 +9072,7 @@ set_up_extended_ref_temp (tree decl, tree expr, VEC(tree,gc) **cleanups, { tree cleanup = cxx_maybe_build_cleanup (var, tf_warning_or_error); if (cleanup) - VEC_safe_push (tree, gc, *cleanups, cleanup); + vec_safe_push (*cleanups, cleanup); } /* We must be careful to destroy the temporary only @@ -9170,7 +9166,7 @@ initialize_reference (tree type, tree expr, which is bound either to a reference or a std::initializer_list. */ static tree -extend_ref_init_temps_1 (tree decl, tree init, VEC(tree,gc) **cleanups) +extend_ref_init_temps_1 (tree decl, tree init, vec<tree, va_gc> **cleanups) { tree sub = init; tree *p; @@ -9201,7 +9197,7 @@ extend_ref_init_temps_1 (tree decl, tree init, VEC(tree,gc) **cleanups) lifetime to match that of DECL. */ tree -extend_ref_init_temps (tree decl, tree init, VEC(tree,gc) **cleanups) +extend_ref_init_temps (tree decl, tree init, vec<tree, va_gc> **cleanups) { tree type = TREE_TYPE (init); if (processing_template_decl) @@ -9226,8 +9222,8 @@ extend_ref_init_temps (tree decl, tree init, VEC(tree,gc) **cleanups) { unsigned i; constructor_elt *p; - VEC(constructor_elt,gc) *elts = CONSTRUCTOR_ELTS (init); - FOR_EACH_VEC_ELT (constructor_elt, elts, i, p) + vec<constructor_elt, va_gc> *elts = CONSTRUCTOR_ELTS (init); + FOR_EACH_VEC_SAFE_ELT (elts, i, p) p->value = extend_ref_init_temps (decl, p->value, cleanups); } diff --git a/gcc/cp/class.c b/gcc/cp/class.c index cdc02ae..56fe1d1 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -79,13 +79,13 @@ typedef struct vtbl_init_data_s tree rtti_binfo; /* The negative-index vtable initializers built up so far. These are in order from least negative index to most negative index. */ - VEC(constructor_elt,gc) *inits; + vec<constructor_elt, va_gc> *inits; /* The binfo for the virtual base for which we're building vcall offset initializers. */ tree vbase; /* The functions in vbase for which we have already provided vcall offsets. */ - VEC(tree,gc) *fns; + vec<tree, va_gc> *fns; /* The vtable index of the next vcall or vbase offset. */ tree index; /* Nonzero if we are building the initializer for the primary @@ -112,7 +112,7 @@ static GTY (()) tree sizeof_biggest_empty_class; /* An array of all local classes present in this translation unit, in declaration order. */ -VEC(tree,gc) *local_classes; +vec<tree, va_gc> *local_classes; static tree get_vfield_name (tree); static void finish_struct_anon (tree); @@ -137,7 +137,7 @@ static tree fixed_type_or_null (tree, int *, int *); static tree build_simple_base_path (tree expr, tree binfo); static tree build_vtbl_ref_1 (tree, tree); static void build_vtbl_initializer (tree, tree, tree, tree, int *, - VEC(constructor_elt,gc) **); + vec<constructor_elt, va_gc> **); static int count_fields (tree); static int add_fields_to_record_type (tree, struct sorted_fields_type*, int); static void insert_into_classtype_sorted_fields (tree, tree, int); @@ -175,15 +175,15 @@ static void dump_vtable (tree, tree, tree); static void dump_vtt (tree, tree); static void dump_thunk (FILE *, int, tree); static tree build_vtable (tree, tree, tree); -static void initialize_vtable (tree, VEC(constructor_elt,gc) *); +static void initialize_vtable (tree, vec<constructor_elt, va_gc> *); static void layout_nonempty_base_or_field (record_layout_info, tree, tree, splay_tree); static tree end_of_class (tree, int); static bool layout_empty_base (record_layout_info, tree, tree, splay_tree); static void accumulate_vtbl_inits (tree, tree, tree, tree, tree, - VEC(constructor_elt,gc) **); + vec<constructor_elt, va_gc> **); static void dfs_accumulate_vtbl_inits (tree, tree, tree, tree, tree, - VEC(constructor_elt,gc) **); + vec<constructor_elt, va_gc> **); static void build_rtti_vtbl_entries (tree, vtbl_init_data *); static void build_vcall_and_vbase_vtbl_entries (tree, vtbl_init_data *); static void clone_constructors_and_destructors (tree); @@ -192,7 +192,8 @@ static void update_vtable_entry_for_fn (tree, tree, tree, tree *, unsigned); static void build_ctor_vtbl_group (tree, tree); static void build_vtt (tree); static tree binfo_ctor_vtable (tree); -static void build_vtt_inits (tree, tree, VEC(constructor_elt,gc) **, tree *); +static void build_vtt_inits (tree, tree, vec<constructor_elt, va_gc> **, + tree *); static tree dfs_build_secondary_vptr_vtt_inits (tree, void *); static tree dfs_fixup_binfo_vtbls (tree, void *); static int record_subobject_offset (tree, tree, splay_tree); @@ -948,7 +949,7 @@ add_method (tree type, tree method, tree using_decl) tree overload; bool template_conv_p = false; bool conv_p; - VEC(tree,gc) *method_vec; + vec<tree, va_gc> *method_vec; bool complete_p; bool insert_p = false; tree current_fns; @@ -970,10 +971,10 @@ add_method (tree type, tree method, tree using_decl) allocate at least two (for constructors and destructors), and we're going to end up with an assignment operator at some point as well. */ - method_vec = VEC_alloc (tree, gc, 8); + vec_alloc (method_vec, 8); /* Create slots for constructors and destructors. */ - VEC_quick_push (tree, method_vec, NULL_TREE); - VEC_quick_push (tree, method_vec, NULL_TREE); + method_vec->quick_push (NULL_TREE); + method_vec->quick_push (NULL_TREE); CLASSTYPE_METHOD_VEC (type) = method_vec; } @@ -1004,7 +1005,7 @@ add_method (tree type, tree method, tree using_decl) insert_p = true; /* See if we already have an entry with this name. */ for (slot = CLASSTYPE_FIRST_CONVERSION_SLOT; - VEC_iterate (tree, method_vec, slot, m); + vec_safe_iterate (method_vec, slot, &m); ++slot) { m = OVL_CURRENT (m); @@ -1028,7 +1029,7 @@ add_method (tree type, tree method, tree using_decl) break; } } - current_fns = insert_p ? NULL_TREE : VEC_index (tree, method_vec, slot); + current_fns = insert_p ? NULL_TREE : (*method_vec)[slot]; /* Check to see if we've already got this method. */ for (fns = current_fns; fns; fns = OVL_NEXT (fns)) @@ -1175,19 +1176,19 @@ add_method (tree type, tree method, tree using_decl) /* We only expect to add few methods in the COMPLETE_P case, so just make room for one more method in that case. */ if (complete_p) - reallocated = VEC_reserve_exact (tree, gc, method_vec, 1); + reallocated = vec_safe_reserve_exact (method_vec, 1); else - reallocated = VEC_reserve (tree, gc, method_vec, 1); + reallocated = vec_safe_reserve (method_vec, 1); if (reallocated) CLASSTYPE_METHOD_VEC (type) = method_vec; - if (slot == VEC_length (tree, method_vec)) - VEC_quick_push (tree, method_vec, overload); + if (slot == method_vec->length ()) + method_vec->quick_push (overload); else - VEC_quick_insert (tree, method_vec, slot, overload); + method_vec->quick_insert (slot, overload); } else /* Replace the current slot. */ - VEC_replace (tree, method_vec, slot, overload); + (*method_vec)[slot] = overload; return true; } @@ -1953,15 +1954,15 @@ resort_type_method_vec (void* obj, gt_pointer_operator new_value, void* cookie) { - VEC(tree,gc) *method_vec = (VEC(tree,gc) *) obj; - int len = VEC_length (tree, method_vec); + vec<tree, va_gc> *method_vec = (vec<tree, va_gc> *) obj; + int len = vec_safe_length (method_vec); size_t slot; tree fn; /* The type conversion ops have to live at the front of the vec, so we can't sort them. */ for (slot = CLASSTYPE_FIRST_CONVERSION_SLOT; - VEC_iterate (tree, method_vec, slot, fn); + vec_safe_iterate (method_vec, slot, &fn); ++slot) if (!DECL_CONV_FN_P (OVL_CURRENT (fn))) break; @@ -1970,7 +1971,7 @@ resort_type_method_vec (void* obj, { resort_data.new_value = new_value; resort_data.cookie = cookie; - qsort (VEC_address (tree, method_vec) + slot, len - slot, sizeof (tree), + qsort (method_vec->address () + slot, len - slot, sizeof (tree), resort_method_name_cmp); } } @@ -1985,14 +1986,14 @@ static void finish_struct_methods (tree t) { tree fn_fields; - VEC(tree,gc) *method_vec; + vec<tree, va_gc> *method_vec; int slot, len; method_vec = CLASSTYPE_METHOD_VEC (t); if (!method_vec) return; - len = VEC_length (tree, method_vec); + len = method_vec->length (); /* Clear DECL_IN_AGGR_P for all functions. */ for (fn_fields = TYPE_METHODS (t); fn_fields; @@ -2006,12 +2007,12 @@ finish_struct_methods (tree t) /* The type conversion ops have to live at the front of the vec, so we can't sort them. */ for (slot = CLASSTYPE_FIRST_CONVERSION_SLOT; - VEC_iterate (tree, method_vec, slot, fn_fields); + method_vec->iterate (slot, &fn_fields); ++slot) if (!DECL_CONV_FN_P (OVL_CURRENT (fn_fields))) break; if (len - slot > 1) - qsort (VEC_address (tree, method_vec) + slot, + qsort (method_vec->address () + slot, len-slot, sizeof (tree), method_name_cmp); } @@ -2103,7 +2104,7 @@ typedef struct find_final_overrider_data_s { /* The candidate overriders. */ tree candidates; /* Path to most derived. */ - VEC(tree,heap) *path; + vec<tree> path; } find_final_overrider_data; /* Add the overrider along the current path to FFOD->CANDIDATES. @@ -2122,7 +2123,7 @@ dfs_find_final_overrider_1 (tree binfo, { depth--; if (dfs_find_final_overrider_1 - (VEC_index (tree, ffod->path, depth), ffod, depth)) + (ffod->path[depth], ffod, depth)) return true; } @@ -2161,8 +2162,8 @@ dfs_find_final_overrider_pre (tree binfo, void *data) find_final_overrider_data *ffod = (find_final_overrider_data *) data; if (binfo == ffod->declaring_base) - dfs_find_final_overrider_1 (binfo, ffod, VEC_length (tree, ffod->path)); - VEC_safe_push (tree, heap, ffod->path, binfo); + dfs_find_final_overrider_1 (binfo, ffod, ffod->path.length ()); + ffod->path.safe_push (binfo); return NULL_TREE; } @@ -2171,7 +2172,7 @@ static tree dfs_find_final_overrider_post (tree /*binfo*/, void *data) { find_final_overrider_data *ffod = (find_final_overrider_data *) data; - VEC_pop (tree, ffod->path); + ffod->path.pop (); return NULL_TREE; } @@ -2211,12 +2212,12 @@ find_final_overrider (tree derived, tree binfo, tree fn) ffod.fn = fn; ffod.declaring_base = binfo; ffod.candidates = NULL_TREE; - ffod.path = VEC_alloc (tree, heap, 30); + ffod.path.create (30); dfs_walk_all (derived, dfs_find_final_overrider_pre, dfs_find_final_overrider_post, &ffod); - VEC_free (tree, heap, ffod.path); + ffod.path.release (); /* If there was no winner, issue an error message. */ if (!ffod.candidates || TREE_CHAIN (ffod.candidates)) @@ -2231,11 +2232,11 @@ find_final_overrider (tree derived, tree binfo, tree fn) static tree get_vcall_index (tree fn, tree type) { - VEC(tree_pair_s,gc) *indices = CLASSTYPE_VCALL_INDICES (type); + vec<tree_pair_s, va_gc> *indices = CLASSTYPE_VCALL_INDICES (type); tree_pair_p p; unsigned ix; - FOR_EACH_VEC_ELT (tree_pair_s, indices, ix, p) + FOR_EACH_VEC_SAFE_ELT (indices, ix, p) if ((DECL_DESTRUCTOR_P (fn) && DECL_DESTRUCTOR_P (p->purpose)) || same_signature_p (fn, p->purpose)) return p->value; @@ -2589,7 +2590,7 @@ get_basefndecls (tree name, tree t) /* Find virtual functions in T with the indicated NAME. */ i = lookup_fnfields_1 (t, name); if (i != -1) - for (methods = VEC_index (tree, CLASSTYPE_METHOD_VEC (t), i); + for (methods = (*CLASSTYPE_METHOD_VEC (t))[i]; methods; methods = OVL_NEXT (methods)) { @@ -2660,13 +2661,13 @@ check_for_override (tree decl, tree ctype) static void warn_hidden (tree t) { - VEC(tree,gc) *method_vec = CLASSTYPE_METHOD_VEC (t); + vec<tree, va_gc> *method_vec = CLASSTYPE_METHOD_VEC (t); tree fns; size_t i; /* We go through each separately named virtual function. */ for (i = CLASSTYPE_FIRST_CONVERSION_SLOT; - VEC_iterate (tree, method_vec, i, fns); + vec_safe_iterate (method_vec, i, &fns); ++i) { tree fn; @@ -3704,7 +3705,7 @@ walk_subobject_offsets (tree type, if (abi_version_at_least (2) && CLASSTYPE_VBASECLASSES (type)) { unsigned ix; - VEC(tree,gc) *vbases; + vec<tree, va_gc> *vbases; /* Iterate through the virtual base classes of TYPE. In G++ 3.2, we included virtual bases in the direct base class @@ -3713,7 +3714,7 @@ walk_subobject_offsets (tree type, working with the most derived type. */ if (vbases_p) for (vbases = CLASSTYPE_VBASECLASSES (type), ix = 0; - VEC_iterate (tree, vbases, ix, binfo); ix++) + vec_safe_iterate (vbases, ix, &binfo); ix++) { r = walk_subobject_offsets (binfo, f, @@ -4221,7 +4222,7 @@ check_methods (tree t) { TYPE_POLYMORPHIC_P (t) = 1; if (DECL_PURE_VIRTUAL_P (x)) - VEC_safe_push (tree, gc, CLASSTYPE_PURE_VIRTUALS (t), x); + vec_safe_push (CLASSTYPE_PURE_VIRTUALS (t), x); } /* All user-provided destructors are non-trivial. Constructors and assignment ops are handled in @@ -5620,7 +5621,7 @@ static tree end_of_class (tree t, int include_virtuals_p) { tree result = size_zero_node; - VEC(tree,gc) *vbases; + vec<tree, va_gc> *vbases; tree binfo; tree base_binfo; tree offset; @@ -5643,7 +5644,7 @@ end_of_class (tree t, int include_virtuals_p) /* G++ 3.2 did not check indirect virtual bases. */ if (abi_version_at_least (2) && include_virtuals_p) for (vbases = CLASSTYPE_VBASECLASSES (t), i = 0; - VEC_iterate (tree, vbases, i, base_binfo); i++) + vec_safe_iterate (vbases, i, &base_binfo); i++) { offset = end_of_base (base_binfo); if (INT_CST_LT_UNSIGNED (result, offset)) @@ -5667,7 +5668,7 @@ static void warn_about_ambiguous_bases (tree t) { int i; - VEC(tree,gc) *vbases; + vec<tree, va_gc> *vbases; tree basetype; tree binfo; tree base_binfo; @@ -5690,7 +5691,7 @@ warn_about_ambiguous_bases (tree t) /* Check for ambiguous virtual bases. */ if (extra_warnings) for (vbases = CLASSTYPE_VBASECLASSES (t), i = 0; - VEC_iterate (tree, vbases, i, binfo); i++) + vec_safe_iterate (vbases, i, &binfo); i++) { basetype = BINFO_TYPE (binfo); @@ -6520,7 +6521,7 @@ finish_struct (tree t, tree attributes) CLASSTYPE_PURE_VIRTUALS (t) = NULL; for (x = TYPE_METHODS (t); x; x = DECL_CHAIN (x)) if (DECL_PURE_VIRTUAL_P (x)) - VEC_safe_push (tree, gc, CLASSTYPE_PURE_VIRTUALS (t), x); + vec_safe_push (CLASSTYPE_PURE_VIRTUALS (t), x); complete_vars (t); /* We need to add the target functions to the CLASSTYPE_METHOD_VEC if an enclosing scope is a template class, so that this function be @@ -6766,7 +6767,7 @@ init_class_processing (void) current_class_stack_size = 10; current_class_stack = XNEWVEC (struct class_stack_node, current_class_stack_size); - local_classes = VEC_alloc (tree, gc, 8); + vec_alloc (local_classes, 8); sizeof_biggest_empty_class = size_zero_node; ridpointers[(int) RID_PUBLIC] = access_public_node; @@ -7028,7 +7029,7 @@ pop_nested_class (void) int current_lang_depth (void) { - return VEC_length (tree, current_lang_base); + return vec_safe_length (current_lang_base); } /* Set global variables CURRENT_LANG_NAME to appropriate value @@ -7037,7 +7038,7 @@ current_lang_depth (void) void push_lang_context (tree name) { - VEC_safe_push (tree, gc, current_lang_base, current_lang_name); + vec_safe_push (current_lang_base, current_lang_name); if (name == lang_name_cplusplus) { @@ -7072,7 +7073,7 @@ push_lang_context (tree name) void pop_lang_context (void) { - current_lang_name = VEC_pop (tree, current_lang_base); + current_lang_name = current_lang_base->pop (); } /* Type instantiation routines. */ @@ -8051,7 +8052,7 @@ static void finish_vtbls (tree t) { tree vbase; - VEC(constructor_elt,gc) *v = NULL; + vec<constructor_elt, va_gc> *v = NULL; tree vtable = BINFO_VTABLE (TYPE_BINFO (t)); /* We lay out the primary and secondary vtables in one contiguous @@ -8075,11 +8076,11 @@ finish_vtbls (tree t) /* Initialize the vtable for BINFO with the INITS. */ static void -initialize_vtable (tree binfo, VEC(constructor_elt,gc) *inits) +initialize_vtable (tree binfo, vec<constructor_elt, va_gc> *inits) { tree decl; - layout_vtable_decl (binfo, VEC_length (constructor_elt, inits)); + layout_vtable_decl (binfo, vec_safe_length (inits)); decl = get_vtbl_decl_for_binfo (binfo); initialize_artificial_var (decl, inits); dump_vtable (BINFO_TYPE (binfo), binfo, decl); @@ -8104,7 +8105,7 @@ build_vtt (tree t) tree type; tree vtt; tree index; - VEC(constructor_elt,gc) *inits; + vec<constructor_elt, va_gc> *inits; /* Build up the initializers for the VTT. */ inits = NULL; @@ -8117,7 +8118,7 @@ build_vtt (tree t) /* Figure out the type of the VTT. */ type = build_array_of_n_type (const_ptr_type_node, - VEC_length (constructor_elt, inits)); + inits->length ()); /* Now, build the VTT object itself. */ vtt = build_vtable (t, mangle_vtt_for_type (t), type); @@ -8163,7 +8164,7 @@ typedef struct secondary_vptr_vtt_init_data_s tree index; /* Vector of initializers built up. */ - VEC(constructor_elt,gc) *inits; + vec<constructor_elt, va_gc> *inits; /* The type being constructed by this secondary VTT. */ tree type_being_constructed; @@ -8178,7 +8179,8 @@ typedef struct secondary_vptr_vtt_init_data_s vtables for the BINFO-in-T variant. */ static void -build_vtt_inits (tree binfo, tree t, VEC(constructor_elt,gc) **inits, tree *index) +build_vtt_inits (tree binfo, tree t, vec<constructor_elt, va_gc> **inits, + tree *index) { int i; tree b; @@ -8338,7 +8340,7 @@ build_ctor_vtbl_group (tree binfo, tree t) tree vtbl; tree id; tree vbase; - VEC(constructor_elt,gc) *v; + vec<constructor_elt, va_gc> *v; /* See if we've already created this construction vtable group. */ id = mangle_ctor_vtbl_for_type (t, binfo); @@ -8372,8 +8374,7 @@ build_ctor_vtbl_group (tree binfo, tree t) } /* Figure out the type of the construction vtable. */ - type = build_array_of_n_type (vtable_entry_type, - VEC_length (constructor_elt, v)); + type = build_array_of_n_type (vtable_entry_type, v->length ()); layout_type (type); TREE_TYPE (vtbl) = type; DECL_SIZE (vtbl) = DECL_SIZE_UNIT (vtbl) = NULL_TREE; @@ -8401,7 +8402,7 @@ accumulate_vtbl_inits (tree binfo, tree rtti_binfo, tree vtbl, tree t, - VEC(constructor_elt,gc) **inits) + vec<constructor_elt, va_gc> **inits) { int i; tree base_binfo; @@ -8449,7 +8450,7 @@ dfs_accumulate_vtbl_inits (tree binfo, tree rtti_binfo, tree orig_vtbl, tree t, - VEC(constructor_elt,gc) **l) + vec<constructor_elt, va_gc> **l) { tree vtbl = NULL_TREE; int ctor_vtbl_p = !SAME_BINFO_TYPE_P (BINFO_TYPE (rtti_binfo), t); @@ -8509,7 +8510,7 @@ dfs_accumulate_vtbl_inits (tree binfo, else if (!BINFO_NEW_VTABLE_MARKED (orig_binfo)) return; - n_inits = VEC_length (constructor_elt, *l); + n_inits = vec_safe_length (*l); if (!vtbl) { @@ -8535,7 +8536,7 @@ dfs_accumulate_vtbl_inits (tree binfo, BINFO_VTABLE (binfo) = tree_cons (rtti_binfo, vtbl, BINFO_VTABLE (binfo)); else if (BINFO_PRIMARY_P (binfo) && BINFO_VIRTUAL_P (binfo)) /* Throw away any unneeded intializers. */ - VEC_truncate (constructor_elt, *l, n_inits); + (*l)->truncate (n_inits); else /* For an ordinary vtable, set BINFO_VTABLE. */ BINFO_VTABLE (binfo) = vtbl; @@ -8572,13 +8573,13 @@ build_vtbl_initializer (tree binfo, tree t, tree rtti_binfo, int* non_fn_entries_p, - VEC(constructor_elt,gc) **inits) + vec<constructor_elt, va_gc> **inits) { tree v; vtbl_init_data vid; unsigned ix, jx; tree vbinfo; - VEC(tree,gc) *vbases; + vec<tree, va_gc> *vbases; constructor_elt *e; /* Initialize VID. */ @@ -8598,41 +8599,39 @@ build_vtbl_initializer (tree binfo, /* Create an array for keeping track of the functions we've processed. When we see multiple functions with the same signature, we share the vcall offsets. */ - vid.fns = VEC_alloc (tree, gc, 32); + vec_alloc (vid.fns, 32); /* Add the vcall and vbase offset entries. */ build_vcall_and_vbase_vtbl_entries (binfo, &vid); /* Clear BINFO_VTABLE_PATH_MARKED; it's set by build_vbase_offset_vtbl_entries. */ for (vbases = CLASSTYPE_VBASECLASSES (t), ix = 0; - VEC_iterate (tree, vbases, ix, vbinfo); ix++) + vec_safe_iterate (vbases, ix, &vbinfo); ix++) BINFO_VTABLE_PATH_MARKED (vbinfo) = 0; /* If the target requires padding between data entries, add that now. */ if (TARGET_VTABLE_DATA_ENTRY_DISTANCE > 1) { - int n_entries = VEC_length (constructor_elt, vid.inits); + int n_entries = vec_safe_length (vid.inits); - VEC_safe_grow (constructor_elt, gc, vid.inits, - TARGET_VTABLE_DATA_ENTRY_DISTANCE * n_entries); + vec_safe_grow (vid.inits, TARGET_VTABLE_DATA_ENTRY_DISTANCE * n_entries); /* Move data entries into their new positions and add padding after the new positions. Iterate backwards so we don't overwrite entries that we would need to process later. */ for (ix = n_entries - 1; - VEC_iterate (constructor_elt, vid.inits, ix, e); + vid.inits->iterate (ix, &e); ix--) { int j; int new_position = (TARGET_VTABLE_DATA_ENTRY_DISTANCE * ix + (TARGET_VTABLE_DATA_ENTRY_DISTANCE - 1)); - VEC_replace (constructor_elt, vid.inits, new_position, *e); + (*vid.inits)[new_position] = *e; for (j = 1; j < TARGET_VTABLE_DATA_ENTRY_DISTANCE; ++j) { - constructor_elt *f = &VEC_index (constructor_elt, vid.inits, - new_position - j); + constructor_elt *f = &(*vid.inits)[new_position - j]; f->index = NULL_TREE; f->value = build1 (NOP_EXPR, vtable_entry_type, null_pointer_node); @@ -8641,19 +8640,18 @@ build_vtbl_initializer (tree binfo, } if (non_fn_entries_p) - *non_fn_entries_p = VEC_length (constructor_elt, vid.inits); + *non_fn_entries_p = vec_safe_length (vid.inits); /* The initializers for virtual functions were built up in reverse order. Straighten them out and add them to the running list in one step. */ - jx = VEC_length (constructor_elt, *inits); - VEC_safe_grow (constructor_elt, gc, *inits, - (jx + VEC_length (constructor_elt, vid.inits))); + jx = vec_safe_length (*inits); + vec_safe_grow (*inits, jx + vid.inits->length ()); - for (ix = VEC_length (constructor_elt, vid.inits) - 1; - VEC_iterate (constructor_elt, vid.inits, ix, e); + for (ix = vid.inits->length () - 1; + vid.inits->iterate (ix, &e); ix--, jx++) - VEC_replace (constructor_elt, *inits, jx, *e); + (**inits)[jx] = *e; /* Go through all the ordinary virtual functions, building up initializers. */ @@ -9053,7 +9051,7 @@ add_vcall_offset (tree orig_fn, tree binfo, vtbl_init_data *vid) signature as FN, then we do not need a second vcall offset. Check the list of functions already present in the derived class vtable. */ - FOR_EACH_VEC_ELT (tree, vid->fns, i, derived_entry) + FOR_EACH_VEC_SAFE_ELT (vid->fns, i, derived_entry) { if (same_signature_p (derived_entry, orig_fn) /* We only use one vcall offset for virtual destructors, @@ -9069,8 +9067,7 @@ add_vcall_offset (tree orig_fn, tree binfo, vtbl_init_data *vid) if (vid->binfo == TYPE_BINFO (vid->derived)) { tree_pair_s elt = {orig_fn, vid->index}; - VEC_safe_push (tree_pair_s, gc, CLASSTYPE_VCALL_INDICES (vid->derived), - elt); + vec_safe_push (CLASSTYPE_VCALL_INDICES (vid->derived), elt); } /* The next vcall offset will be found at a more negative @@ -9079,7 +9076,7 @@ add_vcall_offset (tree orig_fn, tree binfo, vtbl_init_data *vid) ssize_int (TARGET_VTABLE_DATA_ENTRY_DISTANCE)); /* Keep track of this function. */ - VEC_safe_push (tree, gc, vid->fns, orig_fn); + vec_safe_push (vid->fns, orig_fn); if (vid->generate_vcall_entries) { diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index f715e96..cde480d 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -824,7 +824,7 @@ omp_cxx_notice_variable (struct cp_genericize_omp_taskreg *omp_ctx, tree decl) struct cp_genericize_data { struct pointer_set_t *p_set; - VEC (tree, heap) *bind_expr_stack; + vec<tree> bind_expr_stack; struct cp_genericize_omp_taskreg *omp_ctx; }; @@ -1015,10 +1015,10 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) : OMP_CLAUSE_DEFAULT_PRIVATE); } } - VEC_safe_push (tree, heap, wtd->bind_expr_stack, stmt); + wtd->bind_expr_stack.safe_push (stmt); cp_walk_tree (&BIND_EXPR_BODY (stmt), cp_genericize_r, data, NULL); - VEC_pop (tree, wtd->bind_expr_stack); + wtd->bind_expr_stack.pop (); } else if (TREE_CODE (stmt) == USING_STMT) @@ -1028,12 +1028,11 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) /* Get the innermost inclosing GIMPLE_BIND that has a non NULL BLOCK, and append an IMPORTED_DECL to its BLOCK_VARS chained list. */ - if (wtd->bind_expr_stack) + if (wtd->bind_expr_stack.exists ()) { int i; - for (i = VEC_length (tree, wtd->bind_expr_stack) - 1; i >= 0; i--) - if ((block = BIND_EXPR_BLOCK (VEC_index (tree, - wtd->bind_expr_stack, i)))) + for (i = wtd->bind_expr_stack.length () - 1; i >= 0; i--) + if ((block = BIND_EXPR_BLOCK (wtd->bind_expr_stack[i]))) break; } if (block) @@ -1151,11 +1150,11 @@ cp_genericize_tree (tree* t_p) struct cp_genericize_data wtd; wtd.p_set = pointer_set_create (); - wtd.bind_expr_stack = NULL; + wtd.bind_expr_stack.create (0); wtd.omp_ctx = NULL; cp_walk_tree (t_p, cp_genericize_r, &wtd, NULL); pointer_set_destroy (wtd.p_set); - VEC_free (tree, heap, wtd.bind_expr_stack); + wtd.bind_expr_stack.release (); } void diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 7dd6679..8592125 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -535,7 +535,7 @@ typedef enum impl_conv_void { struct GTY (()) tree_default_arg { struct tree_common common; struct cp_token_cache *tokens; - VEC(tree,gc) *instantiations; + vec<tree, va_gc> *instantiations; }; @@ -709,7 +709,7 @@ struct GTY (()) tree_lambda_expr tree return_type; tree extra_scope; tree closure; - VEC(tree,gc)* pending_proxies; + vec<tree, va_gc> *pending_proxies; location_t locus; enum cp_lambda_default_capture_mode_type default_capture_mode; int discriminator; @@ -735,8 +735,6 @@ struct GTY(()) qualified_typedef_usage_s { location_t locus; }; typedef struct qualified_typedef_usage_s qualified_typedef_usage_t; -DEF_VEC_O (qualified_typedef_usage_t); -DEF_VEC_ALLOC_O (qualified_typedef_usage_t,gc); /* Non-zero if this template specialization has access violations that should be rechecked when the function is instantiated outside argument @@ -748,7 +746,7 @@ DEF_VEC_ALLOC_O (qualified_typedef_usage_t,gc); struct GTY(()) tree_template_info { struct tree_common common; - VEC(qualified_typedef_usage_t,gc) *typedefs_needing_access_checking; + vec<qualified_typedef_usage_t, va_gc> *typedefs_needing_access_checking; }; enum cp_tree_node_structure_enum { @@ -986,14 +984,14 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX]; /* Global state. */ struct GTY(()) saved_scope { - VEC(cxx_saved_binding,gc) *old_bindings; + vec<cxx_saved_binding, va_gc> *old_bindings; tree old_namespace; - VEC(tree,gc) *decl_ns_list; + vec<tree, va_gc> *decl_ns_list; tree class_name; tree class_type; tree access_specifier; tree function_decl; - VEC(tree,gc) *lang_base; + vec<tree, va_gc> *lang_base; tree lang_name; tree template_parms; cp_binding_level *x_previous_class_level; @@ -1102,7 +1100,7 @@ struct GTY(()) language_function { htab_t GTY((param_is(struct named_label_entry))) x_named_labels; cp_binding_level *bindings; - VEC(tree,gc) *x_local_names; + vec<tree, va_gc> *x_local_names; htab_t GTY((param_is (struct cxx_int_tree_map))) extern_decl_map; }; @@ -1304,8 +1302,6 @@ typedef struct GTY (()) tree_pair_s { tree value; } tree_pair_s; typedef tree_pair_s *tree_pair_p; -DEF_VEC_O (tree_pair_s); -DEF_VEC_ALLOC_O (tree_pair_s,gc); /* This is a few header flags for 'struct lang_type'. Actually, all but the first are used only for lang_type_class; they @@ -1401,15 +1397,15 @@ struct GTY(()) lang_type_class { unsigned dummy : 2; tree primary_base; - VEC(tree_pair_s,gc) *vcall_indices; + vec<tree_pair_s, va_gc> *vcall_indices; tree vtables; tree typeinfo_var; - VEC(tree,gc) *vbases; + vec<tree, va_gc> *vbases; binding_table nested_udts; tree as_base; - VEC(tree,gc) *pure_virtuals; + vec<tree, va_gc> *pure_virtuals; tree friend_classes; - VEC(tree,gc) * GTY((reorder ("resort_type_method_vec"))) methods; + vec<tree, va_gc> * GTY((reorder ("resort_type_method_vec"))) methods; tree key_method; tree decl_list; tree template_info; @@ -1603,7 +1599,7 @@ struct GTY((variable_size)) lang_type { /* A FUNCTION_DECL or OVERLOAD for the constructors for NODE. These are the constructors that take an in-charge parameter. */ #define CLASSTYPE_CONSTRUCTORS(NODE) \ - (VEC_index (tree, CLASSTYPE_METHOD_VEC (NODE), CLASSTYPE_CONSTRUCTOR_SLOT)) + ((*CLASSTYPE_METHOD_VEC (NODE))[CLASSTYPE_CONSTRUCTOR_SLOT]) /* A FUNCTION_DECL for the destructor for NODE. These are the destructors that take an in-charge parameter. If @@ -1611,7 +1607,7 @@ struct GTY((variable_size)) lang_type { until the destructor is created with lazily_declare_fn. */ #define CLASSTYPE_DESTRUCTORS(NODE) \ (CLASSTYPE_METHOD_VEC (NODE) \ - ? VEC_index (tree, CLASSTYPE_METHOD_VEC (NODE), CLASSTYPE_DESTRUCTOR_SLOT) \ + ? (*CLASSTYPE_METHOD_VEC (NODE))[CLASSTYPE_DESTRUCTOR_SLOT] \ : NULL_TREE) /* A dictionary of the nested user-defined-types (class-types, or enums) @@ -1665,7 +1661,7 @@ struct GTY((variable_size)) lang_type { #define TYPE_JAVA_INTERFACE(NODE) \ (LANG_TYPE_CLASS_CHECK (NODE)->java_interface) -/* A VEC(tree) of virtual functions which cannot be inherited by +/* A vec<tree> of virtual functions which cannot be inherited by derived classes. When deriving from this type, the derived class must provide its own definition for each of these functions. */ #define CLASSTYPE_PURE_VIRTUALS(NODE) \ @@ -1815,7 +1811,7 @@ struct GTY((variable_size)) lang_type { /* Used by various search routines. */ #define IDENTIFIER_MARKED(NODE) TREE_LANG_FLAG_0 (NODE) -/* A VEC(tree_pair_s) of the vcall indices associated with the class +/* A vec<tree_pair_s> of the vcall indices associated with the class NODE. The PURPOSE of each element is a FUNCTION_DECL for a virtual function. The VALUE is the index into the virtual table where the vcall offset for that function is stored, when NODE is a virtual @@ -3345,8 +3341,7 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter) (TREE_CODE (NODE) == CONSTRUCTOR && TREE_HAS_CONSTRUCTOR (NODE)) #define EMPTY_CONSTRUCTOR_P(NODE) (TREE_CODE (NODE) == CONSTRUCTOR \ - && VEC_empty (constructor_elt, \ - CONSTRUCTOR_ELTS (NODE)) \ + && vec_safe_is_empty(CONSTRUCTOR_ELTS(NODE))\ && !TREE_HAS_CONSTRUCTOR (NODE)) /* True if NODE is a init-list used as a direct-initializer, i.e. @@ -4281,7 +4276,7 @@ extern int current_class_depth; /* An array of all local classes present in this translation unit, in declaration order. */ -extern GTY(()) VEC(tree,gc) *local_classes; +extern GTY(()) vec<tree, va_gc> *local_classes; /* Here's where we control how name mangling takes place. */ @@ -4917,20 +4912,20 @@ extern bool sufficient_parms_p (const_tree); extern tree type_decays_to (tree); extern tree build_user_type_conversion (tree, tree, int, tsubst_flags_t); -extern tree build_new_function_call (tree, VEC(tree,gc) **, bool, +extern tree build_new_function_call (tree, vec<tree, va_gc> **, bool, tsubst_flags_t); -extern tree build_operator_new_call (tree, VEC(tree,gc) **, tree *, +extern tree build_operator_new_call (tree, vec<tree, va_gc> **, tree *, tree *, tree, tree *, tsubst_flags_t); -extern tree build_new_method_call (tree, tree, VEC(tree,gc) **, +extern tree build_new_method_call (tree, tree, vec<tree, va_gc> **, tree, int, tree *, tsubst_flags_t); -extern tree build_special_member_call (tree, tree, VEC(tree,gc) **, +extern tree build_special_member_call (tree, tree, vec<tree, va_gc> **, tree, int, tsubst_flags_t); extern tree build_new_op (location_t, enum tree_code, int, tree, tree, tree, tree *, tsubst_flags_t); -extern tree build_op_call (tree, VEC(tree,gc) **, +extern tree build_op_call (tree, vec<tree, va_gc> **, tsubst_flags_t); extern tree build_op_delete_call (enum tree_code, tree, tree, bool, tree, tree, @@ -4954,7 +4949,7 @@ extern tree convert_for_arg_passing (tree, tree, tsubst_flags_t); extern bool is_properly_derived_from (tree, tree); extern tree initialize_reference (tree, tree, int, tsubst_flags_t); -extern tree extend_ref_init_temps (tree, tree, VEC(tree,gc)**); +extern tree extend_ref_init_temps (tree, tree, vec<tree, va_gc>**); extern tree make_temporary_var_for_ref_to_temp (tree, tree); extern tree strip_top_quals (tree); extern bool reference_related_p (tree, tree); @@ -5161,13 +5156,13 @@ extern tree check_elaborated_type_specifier (enum tag_types, tree, bool); extern void warn_extern_redeclared_static (tree, tree); extern tree cxx_comdat_group (tree); extern bool cp_missing_noreturn_ok_p (tree); -extern void initialize_artificial_var (tree, VEC(constructor_elt,gc) *); +extern void initialize_artificial_var (tree, vec<constructor_elt, va_gc> *); extern tree check_var_type (tree, tree); extern tree reshape_init (tree, tree, tsubst_flags_t); extern tree next_initializable_field (tree); extern bool defer_mark_used_calls; -extern GTY(()) VEC(tree, gc) *deferred_mark_used_calls; +extern GTY(()) vec<tree, va_gc> *deferred_mark_used_calls; extern tree finish_case_label (location_t, tree, tree); extern tree cxx_maybe_build_cleanup (tree, tsubst_flags_t); @@ -5199,7 +5194,7 @@ extern void determine_visibility (tree); extern void constrain_class_visibility (tree); extern void import_export_decl (tree); extern tree build_cleanup (tree); -extern tree build_offset_ref_call_from_tree (tree, VEC(tree,gc) **, +extern tree build_offset_ref_call_from_tree (tree, vec<tree, va_gc> **, tsubst_flags_t); extern bool decl_constant_var_p (tree); extern bool decl_maybe_constant_var_p (tree); @@ -5285,8 +5280,8 @@ extern tree build_zero_init (tree, tree, bool); extern tree build_value_init (tree, tsubst_flags_t); extern tree build_value_init_noctor (tree, tsubst_flags_t); extern tree build_offset_ref (tree, tree, bool); -extern tree build_new (VEC(tree,gc) **, tree, tree, - VEC(tree,gc) **, int, +extern tree build_new (vec<tree, va_gc> **, tree, tree, + vec<tree, va_gc> **, int, tsubst_flags_t); extern tree get_temp_regvar (tree, tree); extern tree build_vec_init (tree, tree, tree, bool, int, @@ -5408,7 +5403,7 @@ extern tree make_pack_expansion (tree); extern bool check_for_bare_parameter_packs (tree); extern tree build_template_info (tree, tree); extern tree get_template_info (const_tree); -extern VEC(qualified_typedef_usage_t,gc)* get_types_needing_access_check (tree); +extern vec<qualified_typedef_usage_t, va_gc> *get_types_needing_access_check (tree); extern int template_class_depth (tree); extern int is_specialization_of (tree, tree); extern bool is_specialization_of_friend (tree, tree); @@ -5435,7 +5430,7 @@ extern bool any_dependent_template_arguments_p (const_tree); extern bool dependent_template_p (tree); extern bool dependent_template_id_p (tree, tree); extern bool type_dependent_expression_p (tree); -extern bool any_type_dependent_arguments_p (const VEC(tree,gc) *); +extern bool any_type_dependent_arguments_p (const vec<tree, va_gc> *); extern bool any_type_dependent_elements_p (const_tree); extern bool type_dependent_expression_p_push (tree); extern bool value_dependent_expression_p (tree); @@ -5445,7 +5440,7 @@ extern bool dependent_omp_for_p (tree, tree, tree, tree); extern tree resolve_typename_type (tree, bool); extern tree template_for_substitution (tree); extern tree build_non_dependent_expr (tree); -extern void make_args_non_dependent (VEC(tree,gc) *); +extern void make_args_non_dependent (vec<tree, va_gc> *); extern bool reregister_specialization (tree, tree, tree); extern tree fold_non_dependent_expr (tree); extern tree fold_non_dependent_expr_sfinae (tree, tsubst_flags_t); @@ -5476,7 +5471,7 @@ extern void finish_repo (void); /* in rtti.c */ /* A vector of all tinfo decls that haven't been emitted yet. */ -extern GTY(()) VEC(tree,gc) *unemitted_tinfo_decls; +extern GTY(()) vec<tree, va_gc> *unemitted_tinfo_decls; extern void init_rtti_processing (void); extern tree build_typeid (tree); @@ -5543,17 +5538,15 @@ typedef struct GTY(()) deferred_access_check { /* The location of this access. */ location_t loc; } deferred_access_check; -DEF_VEC_O(deferred_access_check); -DEF_VEC_ALLOC_O(deferred_access_check,gc); /* in semantics.c */ extern void push_deferring_access_checks (deferring_kind); extern void resume_deferring_access_checks (void); extern void stop_deferring_access_checks (void); extern void pop_deferring_access_checks (void); -extern VEC (deferred_access_check,gc)* get_deferred_access_checks (void); +extern vec<deferred_access_check, va_gc> *get_deferred_access_checks (void); extern void pop_to_parent_deferring_access_checks (void); -extern bool perform_access_checks (VEC (deferred_access_check,gc)*, +extern bool perform_access_checks (vec<deferred_access_check, va_gc> *, tsubst_flags_t); extern bool perform_deferred_access_checks (tsubst_flags_t); extern bool perform_or_defer_access_check (tree, tree, tree, @@ -5617,7 +5610,7 @@ extern tree maybe_constant_init (tree); extern bool is_sub_constant_expr (tree); extern bool reduced_constant_expression_p (tree); extern void explain_invalid_constexpr_fn (tree); -extern VEC(tree,heap)* cx_error_context (void); +extern vec<tree> cx_error_context (void); enum { BCS_NO_SCOPE = 1, @@ -5638,9 +5631,9 @@ extern tree finish_stmt_expr_expr (tree, tree); extern tree finish_stmt_expr (tree, bool); extern tree stmt_expr_value_expr (tree); bool empty_expr_stmt_p (tree); -extern tree perform_koenig_lookup (tree, VEC(tree,gc) *, bool, +extern tree perform_koenig_lookup (tree, vec<tree, va_gc> *, bool, tsubst_flags_t); -extern tree finish_call_expr (tree, VEC(tree,gc) **, bool, +extern tree finish_call_expr (tree, vec<tree, va_gc> **, bool, bool, tsubst_flags_t); extern tree finish_increment_expr (tree, enum tree_code); extern tree finish_this_expr (void); @@ -5766,7 +5759,7 @@ extern tree build_min (enum tree_code, tree, ...); extern tree build_min_nt_loc (location_t, enum tree_code, ...); extern tree build_min_non_dep (enum tree_code, tree, ...); -extern tree build_min_non_dep_call_vec (tree, tree, VEC(tree,gc) *); +extern tree build_min_non_dep_call_vec (tree, tree, vec<tree, va_gc> *); extern tree build_cplus_new (tree, tree, tsubst_flags_t); extern tree build_aggr_init_expr (tree, tree, tsubst_flags_t); extern tree get_target_expr (tree); @@ -5887,7 +5880,7 @@ extern tree get_member_function_from_ptrfunc (tree *, tree, tsubst_flags_t); extern tree cp_build_function_call (tree, tree, tsubst_flags_t); extern tree cp_build_function_call_nary (tree, tsubst_flags_t, ...) ATTRIBUTE_SENTINEL; -extern tree cp_build_function_call_vec (tree, VEC(tree,gc) **, +extern tree cp_build_function_call_vec (tree, vec<tree, va_gc> **, tsubst_flags_t); extern tree build_x_binary_op (location_t, enum tree_code, tree, @@ -5908,8 +5901,8 @@ extern tree build_x_conditional_expr (location_t, tree, tree, tree, tsubst_flags_t); extern tree build_x_compound_expr_from_list (tree, expr_list_kind, tsubst_flags_t); -extern tree build_x_compound_expr_from_vec (VEC(tree,gc) *, const char *, - tsubst_flags_t); +extern tree build_x_compound_expr_from_vec (vec<tree, va_gc> *, + const char *, tsubst_flags_t); extern tree build_x_compound_expr (location_t, tree, tree, tsubst_flags_t); extern tree build_compound_expr (location_t, tree, tree); @@ -5985,7 +5978,7 @@ extern void complete_type_check_abstract (tree); extern int abstract_virtuals_error (tree, tree); extern int abstract_virtuals_error_sfinae (tree, tree, tsubst_flags_t); -extern tree store_init_value (tree, tree, VEC(tree,gc)**, int); +extern tree store_init_value (tree, tree, vec<tree, va_gc>**, int); extern void check_narrowing (tree, tree); extern tree digest_init (tree, tree, tsubst_flags_t); extern tree digest_init_flags (tree, tree, int); diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index d30c7e5..1dc7898 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -561,7 +561,7 @@ force_rvalue (tree expr, tsubst_flags_t complain) tree type = TREE_TYPE (expr); if (MAYBE_CLASS_TYPE_P (type) && TREE_CODE (expr) != TARGET_EXPR) { - VEC(tree,gc) *args = make_tree_vector_single (expr); + vec<tree, va_gc> *args = make_tree_vector_single (expr); expr = build_special_member_call (NULL_TREE, complete_ctor_identifier, &args, type, LOOKUP_NORMAL, complain); release_tree_vector (args); @@ -855,7 +855,7 @@ ocp_convert (tree type, tree expr, int convtype, int flags, ctor = build_user_type_conversion (type, ctor, flags, complain); else { - VEC(tree,gc) *ctor_vec = make_tree_vector_single (ctor); + vec<tree, va_gc> *ctor_vec = make_tree_vector_single (ctor); ctor = build_special_member_call (NULL_TREE, complete_ctor_identifier, &ctor_vec, diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 045e99b..bae48ce 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -91,7 +91,7 @@ static tree lookup_and_check_tag (enum tag_types, tree, tag_scope, bool); static int walk_namespaces_r (tree, walk_namespaces_fn, void *); static void maybe_deduce_size_from_array_init (tree, tree); static void layout_var_decl (tree); -static tree check_initializer (tree, tree, int, VEC(tree,gc) **); +static tree check_initializer (tree, tree, int, vec<tree, va_gc> **); static void make_rtl_for_nonlocal_decl (tree, tree, const char *); static void save_function_data (tree); static void copy_type_enum (tree , tree); @@ -218,7 +218,7 @@ struct GTY(()) named_label_entry { tree names_in_scope; /* A vector of all decls from all binding levels that would be crossed by a backward branch to the label. */ - VEC(tree,gc) *bad_decls; + vec<tree, va_gc> *bad_decls; /* A list of uses of the label, before the label is defined. */ struct named_label_use_entry *uses; @@ -241,7 +241,7 @@ int function_depth; /* To avoid unwanted recursion, finish_function defers all mark_used calls encountered during its execution until it finishes. */ bool defer_mark_used_calls; -VEC(tree, gc) *deferred_mark_used_calls; +vec<tree, va_gc> *deferred_mark_used_calls; /* States indicating how grokdeclarator() should handle declspecs marked with __attribute__((deprecated)). An object declared as @@ -258,10 +258,8 @@ typedef struct GTY(()) incomplete_var_d { tree incomplete_type; } incomplete_var; -DEF_VEC_O(incomplete_var); -DEF_VEC_ALLOC_O(incomplete_var,gc); -static GTY(()) VEC(incomplete_var,gc) *incomplete_vars; +static GTY(()) vec<incomplete_var, va_gc> *incomplete_vars; /* Returns the kind of template specialization we are currently processing, given that it's declaration contained N_CLASS_SCOPES @@ -486,7 +484,7 @@ poplevel_named_label_1 (void **slot, void *data) ? DECL_CHAIN (decl) : TREE_CHAIN (decl))) if (decl_jump_unsafe (decl)) - VEC_safe_push (tree, gc, ent->bad_decls, decl); + vec_safe_push (ent->bad_decls, decl); ent->binding_level = obl; ent->names_in_scope = obl->names; @@ -567,8 +565,7 @@ poplevel (int keep, int reverse, int functionbody) functionbody = 0; subblocks = functionbody >= 0 ? current_binding_level->blocks : 0; - gcc_assert (!VEC_length(cp_class_binding, - current_binding_level->class_shadowed)); + gcc_assert (!vec_safe_length (current_binding_level->class_shadowed)); /* We used to use KEEP == 2 to indicate that the new block should go at the beginning of the list of blocks at this binding level, @@ -708,9 +705,9 @@ poplevel (int keep, int reverse, int functionbody) /* Add it to the list of dead variables in the next outermost binding to that we can remove these when we leave that binding. */ - VEC_safe_push (tree, gc, - current_binding_level->level_chain->dead_vars_from_for, - link); + vec_safe_push ( + current_binding_level->level_chain->dead_vars_from_for, + link); /* Although we don't pop the cxx_binding, we do clear its SCOPE since the scope is going away now. */ @@ -739,8 +736,8 @@ poplevel (int keep, int reverse, int functionbody) /* Remove declarations for any `for' variables from inner scopes that we kept around. */ - FOR_EACH_VEC_ELT_REVERSE (tree, current_binding_level->dead_vars_from_for, - ix, decl) + FOR_EACH_VEC_SAFE_ELT_REVERSE (current_binding_level->dead_vars_from_for, + ix, decl) pop_binding (DECL_NAME (decl), decl); /* Restore the IDENTIFIER_TYPE_VALUEs. */ @@ -749,9 +746,8 @@ poplevel (int keep, int reverse, int functionbody) SET_IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (link), TREE_VALUE (link)); /* Restore the IDENTIFIER_LABEL_VALUEs for local labels. */ - FOR_EACH_VEC_ELT_REVERSE (cp_label_binding, - current_binding_level->shadowed_labels, - ix, label_bind) + FOR_EACH_VEC_SAFE_ELT_REVERSE (current_binding_level->shadowed_labels, + ix, label_bind) pop_local_label (label_bind->label, label_bind->prev_value); /* There may be OVERLOADs (wrapped in TREE_LISTs) on the BLOCK_VARs @@ -866,9 +862,9 @@ int wrapup_globals_for_namespace (tree name_space, void* data) { cp_binding_level *level = NAMESPACE_LEVEL (name_space); - VEC(tree,gc) *statics = level->static_decls; - tree *vec = VEC_address (tree, statics); - int len = VEC_length (tree, statics); + vec<tree, va_gc> *statics = level->static_decls; + tree *vec = statics->address (); + int len = statics->length (); int last_time = (data != 0); if (last_time) @@ -917,10 +913,10 @@ push_local_name (tree decl) name = DECL_NAME (decl); - nelts = VEC_length (tree, local_names); + nelts = vec_safe_length (local_names); for (i = 0; i < nelts; i++) { - t = VEC_index (tree, local_names, i); + t = (*local_names)[i]; if (DECL_NAME (t) == name) { if (!DECL_LANG_SPECIFIC (decl)) @@ -931,13 +927,13 @@ push_local_name (tree decl) else DECL_DISCRIMINATOR (decl) = 1; - VEC_replace (tree, local_names, i, decl); + (*local_names)[i] = decl; timevar_stop (TV_NAME_LOOKUP); return; } } - VEC_safe_push (tree, gc, local_names, decl); + vec_safe_push (local_names, decl); timevar_stop (TV_NAME_LOOKUP); } @@ -2706,8 +2702,7 @@ declare_local_label (tree id) decl = make_label_decl (id, /*local_p=*/1); bind.label = decl; - VEC_safe_push (cp_label_binding, gc, current_binding_level->shadowed_labels, - bind); + vec_safe_push (current_binding_level->shadowed_labels, bind); return decl; } @@ -2890,14 +2885,14 @@ check_goto (tree decl) } if (ent->in_try_scope || ent->in_catch_scope - || ent->in_omp_scope || !VEC_empty (tree, ent->bad_decls)) + || ent->in_omp_scope || !vec_safe_is_empty (ent->bad_decls)) { permerror (input_location, "jump to label %q+D", decl); permerror (input_location, " from here"); identified = true; } - FOR_EACH_VEC_ELT (tree, ent->bad_decls, ix, bad) + FOR_EACH_VEC_SAFE_ELT (ent->bad_decls, ix, bad) { int u = decl_jump_unsafe (bad); @@ -4824,10 +4819,10 @@ maybe_deduce_size_from_array_init (tree decl, tree init) initializer. */ if (initializer && TREE_CODE (initializer) == CONSTRUCTOR) { - VEC(constructor_elt,gc) *v = CONSTRUCTOR_ELTS (initializer); + vec<constructor_elt, va_gc> *v = CONSTRUCTOR_ELTS (initializer); constructor_elt *ce; HOST_WIDE_INT i; - FOR_EACH_VEC_ELT (constructor_elt, v, i, ce) + FOR_EACH_VEC_SAFE_ELT (v, i, ce) if (!check_array_designated_initializer (ce, i)) failure = 1; } @@ -5308,7 +5303,7 @@ reshape_init_r (tree type, reshape_iter *d, bool first_initializer_p, } else if (first_initializer_p && d->cur != d->end) { - VEC(constructor_elt, gc) *v = 0; + vec<constructor_elt, va_gc> *v = 0; CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, init); CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, d->cur->value); if (has_designator_problem (d, complain)) @@ -5382,10 +5377,9 @@ reshape_init_r (tree type, reshape_iter *d, bool first_initializer_p, element (as allowed by [dcl.init.string]). */ if (!first_initializer_p && TREE_CODE (str_init) == CONSTRUCTOR - && VEC_length (constructor_elt, CONSTRUCTOR_ELTS (str_init)) == 1) + && vec_safe_length (CONSTRUCTOR_ELTS (str_init)) == 1) { - str_init = VEC_index (constructor_elt, - CONSTRUCTOR_ELTS (str_init), 0).value; + str_init = (*CONSTRUCTOR_ELTS (str_init))[0].value; } /* If it's a string literal, then it's the initializer for the array @@ -5453,15 +5447,15 @@ reshape_init_r (tree type, reshape_iter *d, bool first_initializer_p, struct S { int a; int b; }; struct S a[] = { 1, 2, 3, 4 }; - Here INIT will hold a VEC of four elements, rather than a - VEC of two elements, each itself a VEC of two elements. This + Here INIT will hold a vector of four elements, rather than a + vector of two elements, each itself a vector of two elements. This routine transforms INIT from the former form into the latter. The revised CONSTRUCTOR node is returned. */ tree reshape_init (tree type, tree init, tsubst_flags_t complain) { - VEC(constructor_elt, gc) *v; + vec<constructor_elt, va_gc> *v; reshape_iter d; tree new_init; @@ -5471,12 +5465,12 @@ reshape_init (tree type, tree init, tsubst_flags_t complain) /* An empty constructor does not need reshaping, and it is always a valid initializer. */ - if (VEC_empty (constructor_elt, v)) + if (vec_safe_is_empty (v)) return init; /* Recurse on this CONSTRUCTOR. */ - d.cur = &VEC_index (constructor_elt, v, 0); - d.end = d.cur + VEC_length (constructor_elt, v); + d.cur = &(*v)[0]; + d.end = d.cur + v->length (); new_init = reshape_init_r (type, &d, true, complain); if (new_init == error_mark_node) @@ -5546,7 +5540,7 @@ build_aggr_init_full_exprs (tree decl, tree init, int flags) evaluated dynamically to initialize DECL. */ static tree -check_initializer (tree decl, tree init, int flags, VEC(tree,gc) **cleanups) +check_initializer (tree decl, tree init, int flags, vec<tree, va_gc> **cleanups) { tree type = TREE_TYPE (decl); tree init_code = NULL; @@ -5586,7 +5580,7 @@ check_initializer (tree decl, tree init, int flags, VEC(tree,gc) **cleanups) if (init && BRACE_ENCLOSED_INITIALIZER_P (init)) { - int init_len = VEC_length (constructor_elt, CONSTRUCTOR_ELTS (init)); + int init_len = vec_safe_length (CONSTRUCTOR_ELTS (init)); if (SCALAR_TYPE_P (type)) { if (init_len == 0) @@ -5991,7 +5985,7 @@ initialize_local_var (tree decl, tree init) back end. */ void -initialize_artificial_var (tree decl, VEC(constructor_elt,gc) *v) +initialize_artificial_var (tree decl, vec<constructor_elt, va_gc> *v) { tree init; gcc_assert (DECL_ARTIFICIAL (decl)); @@ -6017,15 +6011,14 @@ type_dependent_init_p (tree init) else if (TREE_CODE (init) == CONSTRUCTOR) /* A brace-enclosed initializer, e.g.: int i = { 3 }; ? */ { - VEC(constructor_elt, gc) *elts; + vec<constructor_elt, va_gc> *elts; size_t nelts; size_t i; elts = CONSTRUCTOR_ELTS (init); - nelts = VEC_length (constructor_elt, elts); + nelts = vec_safe_length (elts); for (i = 0; i < nelts; ++i) - if (type_dependent_init_p (VEC_index (constructor_elt, - elts, i).value)) + if (type_dependent_init_p ((*elts)[i].value)) return true; } else @@ -6047,15 +6040,14 @@ value_dependent_init_p (tree init) else if (TREE_CODE (init) == CONSTRUCTOR) /* A brace-enclosed initializer, e.g.: int i = { 3 }; ? */ { - VEC(constructor_elt, gc) *elts; + vec<constructor_elt, va_gc> *elts; size_t nelts; size_t i; elts = CONSTRUCTOR_ELTS (init); - nelts = VEC_length (constructor_elt, elts); + nelts = vec_safe_length (elts); for (i = 0; i < nelts; ++i) - if (value_dependent_init_p (VEC_index (constructor_elt, - elts, i).value)) + if (value_dependent_init_p ((*elts)[i].value)) return true; } else @@ -6081,7 +6073,7 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, tree asmspec_tree, int flags) { tree type; - VEC(tree,gc) *cleanups = NULL; + vec<tree, va_gc> *cleanups = NULL; const char *asmspec = NULL; int was_readonly = 0; bool var_definition_p = false; @@ -6489,7 +6481,7 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, if (cleanups) { unsigned i; tree t; - FOR_EACH_VEC_ELT (tree, cleanups, i, t) + FOR_EACH_VEC_ELT (*cleanups, i, t) push_cleanup (decl, t, false); release_tree_vector (cleanups); } @@ -6769,7 +6761,7 @@ register_dtor_fn (tree decl) /* Find the destructor. */ idx = lookup_fnfields_1 (type, complete_dtor_identifier); gcc_assert (idx >= 0); - cleanup = VEC_index (tree, CLASSTYPE_METHOD_VEC (type), idx); + cleanup = (*CLASSTYPE_METHOD_VEC (type))[idx]; /* Make sure it is accessible. */ perform_or_defer_access_check (TYPE_BINFO (type), cleanup, cleanup, tf_warning_or_error); @@ -7053,13 +7045,13 @@ cp_complete_array_type (tree *ptype, tree initial_value, bool do_default) we should just call reshape_init here? */ if (char_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (*ptype))) && TREE_CODE (initial_value) == CONSTRUCTOR - && !VEC_empty (constructor_elt, CONSTRUCTOR_ELTS (initial_value))) + && !vec_safe_is_empty (CONSTRUCTOR_ELTS (initial_value))) { - VEC(constructor_elt,gc) *v = CONSTRUCTOR_ELTS (initial_value); - tree value = VEC_index (constructor_elt, v, 0).value; + vec<constructor_elt, va_gc> *v = CONSTRUCTOR_ELTS (initial_value); + tree value = (*v)[0].value; if (TREE_CODE (value) == STRING_CST - && VEC_length (constructor_elt, v) == 1) + && v->length () == 1) initial_value = value; } @@ -12108,7 +12100,7 @@ xref_basetypes (tree ref, tree base_list) if (TREE_TYPE (*basep)) max_vbases++; if (CLASS_TYPE_P (basetype)) - max_vbases += VEC_length (tree, CLASSTYPE_VBASECLASSES (basetype)); + max_vbases += vec_safe_length (CLASSTYPE_VBASECLASSES (basetype)); basep = &TREE_CHAIN (*basep); } } @@ -12136,7 +12128,7 @@ xref_basetypes (tree ref, tree base_list) if (max_bases) { - BINFO_BASE_ACCESSES (binfo) = VEC_alloc (tree, gc, max_bases); + vec_alloc (BINFO_BASE_ACCESSES (binfo), max_bases); /* An aggregate cannot have baseclasses. */ CLASSTYPE_NON_AGGREGATE (ref) = 1; @@ -12158,7 +12150,7 @@ xref_basetypes (tree ref, tree base_list) if (max_vbases) { - CLASSTYPE_VBASECLASSES (ref) = VEC_alloc (tree, gc, max_vbases); + vec_alloc (CLASSTYPE_VBASECLASSES (ref), max_vbases); if (TYPE_FOR_JAVA (ref)) { @@ -12236,7 +12228,7 @@ xref_basetypes (tree ref, tree base_list) BINFO_BASE_ACCESS_APPEND (binfo, access); } - if (VEC_length (tree, CLASSTYPE_VBASECLASSES (ref)) < max_vbases) + if (vec_safe_length (CLASSTYPE_VBASECLASSES (ref)) < max_vbases) /* If we didn't get max_vbases vbases, we must have shared at least one of them, and are therefore diamond shaped. */ CLASSTYPE_DIAMOND_SHAPED_P (ref) = 1; @@ -13919,9 +13911,9 @@ finish_function (int flags) unsigned int i; tree decl; - FOR_EACH_VEC_ELT (tree, deferred_mark_used_calls, i, decl) + FOR_EACH_VEC_SAFE_ELT (deferred_mark_used_calls, i, decl) mark_used (decl); - VEC_free (tree, gc, deferred_mark_used_calls); + vec_free (deferred_mark_used_calls); } return fndecl; @@ -14032,7 +14024,7 @@ maybe_register_incomplete_var (tree var) && TYPE_BEING_DEFINED (inner_type))) { incomplete_var iv = {var, inner_type}; - VEC_safe_push (incomplete_var, gc, incomplete_vars, iv); + vec_safe_push (incomplete_vars, iv); } } } @@ -14047,7 +14039,7 @@ complete_vars (tree type) unsigned ix; incomplete_var *iv; - for (ix = 0; VEC_iterate (incomplete_var, incomplete_vars, ix, iv); ) + for (ix = 0; vec_safe_iterate (incomplete_vars, ix, &iv); ) { if (same_type_p (type, iv->incomplete_type)) { @@ -14058,7 +14050,7 @@ complete_vars (tree type) complete_type (type); cp_apply_type_quals_to_decl (cp_type_quals (type), var); /* Remove this entry from the list. */ - VEC_unordered_remove (incomplete_var, incomplete_vars, ix); + incomplete_vars->unordered_remove (ix); } else ix++; diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 9f20757..9ed53b8 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -90,15 +90,15 @@ static bool decl_defined_p (tree); /* A list of static class variables. This is needed, because a static class variable can be declared inside the class without an initializer, and then initialized, statically, outside the class. */ -static GTY(()) VEC(tree,gc) *pending_statics; +static GTY(()) vec<tree, va_gc> *pending_statics; /* A list of functions which were declared inline, but which we may need to emit outline anyway. */ -static GTY(()) VEC(tree,gc) *deferred_fns; +static GTY(()) vec<tree, va_gc> *deferred_fns; /* A list of decls that use types with no linkage, which we need to make sure are defined. */ -static GTY(()) VEC(tree,gc) *no_linkage_decls; +static GTY(()) vec<tree, va_gc> *no_linkage_decls; /* Nonzero if we're done parsing and into end-of-file activities. */ @@ -644,12 +644,12 @@ check_classfn (tree ctype, tree function, tree template_parms) ix = class_method_index_for_fn (complete_type (ctype), function); if (ix >= 0) { - VEC(tree,gc) *methods = CLASSTYPE_METHOD_VEC (ctype); + vec<tree, va_gc> *methods = CLASSTYPE_METHOD_VEC (ctype); tree fndecls, fndecl = 0; bool is_conv_op; const char *format = NULL; - for (fndecls = VEC_index (tree, methods, ix); + for (fndecls = (*methods)[ix]; fndecls; fndecls = OVL_NEXT (fndecls)) { tree p1, p2; @@ -705,7 +705,7 @@ check_classfn (tree ctype, tree function, tree template_parms) if (is_conv_op) ix = CLASSTYPE_FIRST_CONVERSION_SLOT; - fndecls = VEC_index (tree, methods, ix); + fndecls = (*methods)[ix]; while (fndecls) { fndecl = OVL_CURRENT (fndecls); @@ -713,9 +713,9 @@ check_classfn (tree ctype, tree function, tree template_parms) if (!fndecls && is_conv_op) { - if (VEC_length (tree, methods) > (size_t) ++ix) + if (methods->length () > (size_t) ++ix) { - fndecls = VEC_index (tree, methods, ix); + fndecls = (*methods)[ix]; if (!DECL_CONV_FN_P (OVL_CURRENT (fndecls))) { fndecls = NULL_TREE; @@ -753,7 +753,7 @@ void note_vague_linkage_fn (tree decl) { DECL_DEFER_OUTPUT (decl) = 1; - VEC_safe_push (tree, gc, deferred_fns, decl); + vec_safe_push (deferred_fns, decl); } /* We have just processed the DECL, which is a static data member. @@ -772,7 +772,7 @@ finish_static_data_member_decl (tree decl, the right thing, namely, to put this decl out straight away. */ if (! processing_template_decl) - VEC_safe_push (tree, gc, pending_statics, decl); + vec_safe_push (pending_statics, decl); if (LOCAL_CLASS_P (current_class_type) /* We already complained about the template definition. */ @@ -1879,7 +1879,7 @@ maybe_emit_vtables (tree ctype) if (TREE_TYPE (DECL_INITIAL (vtbl)) == 0) { - VEC(tree,gc)* cleanups = NULL; + vec<tree, va_gc> *cleanups = NULL; tree expr = store_init_value (vtbl, DECL_INITIAL (vtbl), &cleanups, LOOKUP_NORMAL); @@ -3063,7 +3063,7 @@ static GTY(()) tree ssdf_decl; /* All the static storage duration functions created in this translation unit. */ -static GTY(()) VEC(tree,gc) *ssdf_decls; +static GTY(()) vec<tree, va_gc> *ssdf_decls; /* A map from priority levels to information about that priority level. There may be many such levels, so efficient lookup is @@ -3108,7 +3108,7 @@ start_static_storage_duration_function (unsigned count) static constructors and destructors. */ if (!ssdf_decls) { - ssdf_decls = VEC_alloc (tree, gc, 32); + vec_alloc (ssdf_decls, 32); /* Take this opportunity to initialize the map from priority numbers to information about that priority level. */ @@ -3124,7 +3124,7 @@ start_static_storage_duration_function (unsigned count) get_priority_info (DEFAULT_INIT_PRIORITY); } - VEC_safe_push (tree, gc, ssdf_decls, ssdf_decl); + vec_safe_push (ssdf_decls, ssdf_decl); /* Create the argument list. */ initialize_p_decl = cp_build_parm_decl @@ -3568,7 +3568,7 @@ generate_ctor_or_dtor_function (bool constructor_p, int priority, /* Call the static storage duration function with appropriate arguments. */ - FOR_EACH_VEC_ELT (tree, ssdf_decls, i, fndecl) + FOR_EACH_VEC_SAFE_ELT (ssdf_decls, i, fndecl) { /* Calls to pure or const functions will expand to nothing. */ if (! (flags_from_decl_or_type (fndecl) & (ECF_CONST | ECF_PURE))) @@ -3941,7 +3941,7 @@ cp_write_global_declarations (void) /* Bad parse errors. Just forget about it. */ if (! global_bindings_p () || current_class_type - || !VEC_empty (tree,decl_namespace_list)) + || !vec_safe_is_empty (decl_namespace_list)) return; if (pch_file) @@ -4031,12 +4031,12 @@ cp_write_global_declarations (void) cause other variables to be needed. New elements will be appended, and we remove from the vector those that actually get emitted. */ - for (i = VEC_length (tree, unemitted_tinfo_decls); - VEC_iterate (tree, unemitted_tinfo_decls, --i, t);) + for (i = unemitted_tinfo_decls->length (); + unemitted_tinfo_decls->iterate (--i, &t);) if (emit_tinfo_decl (t)) { reconsider = true; - VEC_unordered_remove (tree, unemitted_tinfo_decls, i); + unemitted_tinfo_decls->unordered_remove (i); } /* The list of objects with static storage duration is built up @@ -4102,7 +4102,7 @@ cp_write_global_declarations (void) /* Go through the set of inline functions whose bodies have not been emitted yet. If out-of-line copies of these functions are required, emit them. */ - FOR_EACH_VEC_ELT (tree, deferred_fns, i, decl) + FOR_EACH_VEC_SAFE_ELT (deferred_fns, i, decl) { /* Does it need synthesizing? */ if (DECL_DEFAULTED_FN (decl) && ! DECL_INITIAL (decl) @@ -4196,7 +4196,7 @@ cp_write_global_declarations (void) reconsider = true; /* Static data members are just like namespace-scope globals. */ - FOR_EACH_VEC_ELT (tree, pending_statics, i, decl) + FOR_EACH_VEC_SAFE_ELT (pending_statics, i, decl) { if (var_finalized_p (decl) || DECL_REALLY_EXTERN (decl) /* Don't write it out if we haven't seen a definition. */ @@ -4208,9 +4208,9 @@ cp_write_global_declarations (void) if (DECL_NOT_REALLY_EXTERN (decl) && decl_needed_p (decl)) DECL_EXTERNAL (decl) = 0; } - if (VEC_length (tree, pending_statics) != 0 - && wrapup_global_declarations (VEC_address (tree, pending_statics), - VEC_length (tree, pending_statics))) + if (vec_safe_length (pending_statics) != 0 + && wrapup_global_declarations (pending_statics->address (), + pending_statics->length ())) reconsider = true; retries++; @@ -4218,7 +4218,7 @@ cp_write_global_declarations (void) while (reconsider); /* All used inline functions must have a definition at this point. */ - FOR_EACH_VEC_ELT (tree, deferred_fns, i, decl) + FOR_EACH_VEC_SAFE_ELT (deferred_fns, i, decl) { if (/* Check online inline functions that were actually used. */ DECL_ODR_USED (decl) && DECL_DECLARED_INLINE_P (decl) @@ -4240,7 +4240,7 @@ cp_write_global_declarations (void) } /* So must decls that use a type with no linkage. */ - FOR_EACH_VEC_ELT (tree, no_linkage_decls, i, decl) + FOR_EACH_VEC_SAFE_ELT (no_linkage_decls, i, decl) if (!decl_defined_p (decl)) no_linkage_error (decl); @@ -4292,12 +4292,12 @@ cp_write_global_declarations (void) /* Now, issue warnings about static, but not defined, functions, etc., and emit debugging information. */ walk_namespaces (wrapup_globals_for_namespace, /*data=*/&reconsider); - if (VEC_length (tree, pending_statics) != 0) + if (vec_safe_length (pending_statics) != 0) { - check_global_declarations (VEC_address (tree, pending_statics), - VEC_length (tree, pending_statics)); - emit_debug_global_declarations (VEC_address (tree, pending_statics), - VEC_length (tree, pending_statics)); + check_global_declarations (pending_statics->address (), + pending_statics->length ()); + emit_debug_global_declarations (pending_statics->address (), + pending_statics->length ()); } perform_deferred_noexcept_checks (); @@ -4345,11 +4345,11 @@ cp_write_global_declarations (void) ARGS. */ tree -build_offset_ref_call_from_tree (tree fn, VEC(tree,gc) **args, +build_offset_ref_call_from_tree (tree fn, vec<tree, va_gc> **args, tsubst_flags_t complain) { tree orig_fn; - VEC(tree,gc) *orig_args = NULL; + vec<tree, va_gc> *orig_args = NULL; tree expr; tree object; @@ -4375,7 +4375,7 @@ build_offset_ref_call_from_tree (tree fn, VEC(tree,gc) **args, { if (TREE_CODE (fn) == DOTSTAR_EXPR) object = cp_build_addr_expr (object, complain); - VEC_safe_insert (tree, gc, *args, 0, object); + vec_safe_insert (*args, 0, object); } /* Now that the arguments are done, transform FN. */ fn = build_non_dependent_expr (fn); @@ -4393,7 +4393,7 @@ build_offset_ref_call_from_tree (tree fn, VEC(tree,gc) **args, fn = TREE_OPERAND (fn, 1); fn = get_member_function_from_ptrfunc (&object_addr, fn, complain); - VEC_safe_insert (tree, gc, *args, 0, object_addr); + vec_safe_insert (*args, 0, object_addr); } if (CLASS_TYPE_P (TREE_TYPE (fn))) @@ -4519,7 +4519,7 @@ mark_used (tree decl) finishes, otherwise it might recurse. */ if (defer_mark_used_calls) { - VEC_safe_push (tree, gc, deferred_mark_used_calls, decl); + vec_safe_push (deferred_mark_used_calls, decl); return true; } @@ -4589,7 +4589,7 @@ mark_used (tree decl) the vector interferes with GC, so give an error now. */ no_linkage_error (decl); else - VEC_safe_push (tree, gc, no_linkage_decls, decl); + vec_safe_push (no_linkage_decls, decl); } if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl) diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 76f939f..1980cd3 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -84,7 +84,7 @@ static void dump_exception_spec (tree, int); static void dump_template_argument (tree, int); static void dump_template_argument_list (tree, int); static void dump_template_parameter (tree, int); -static void dump_template_bindings (tree, tree, VEC(tree,gc) *); +static void dump_template_bindings (tree, tree, vec<tree, va_gc> *); static void dump_scope (tree, int); static void dump_template_parms (tree, int, int); static int get_non_default_template_args_count (tree, int); @@ -259,7 +259,7 @@ dump_template_parameter (tree parm, int flags) TREE_VEC. */ static void -dump_template_bindings (tree parms, tree args, VEC(tree,gc)* typenames) +dump_template_bindings (tree parms, tree args, vec<tree, va_gc> *typenames) { bool need_semicolon = false; int i; @@ -310,10 +310,10 @@ dump_template_bindings (tree parms, tree args, VEC(tree,gc)* typenames) } /* Don't bother with typenames for a partial instantiation. */ - if (VEC_empty (tree, typenames) || uses_template_parms (args)) + if (vec_safe_is_empty (typenames) || uses_template_parms (args)) return; - FOR_EACH_VEC_ELT (tree, typenames, i, t) + FOR_EACH_VEC_SAFE_ELT (typenames, i, t) { if (need_semicolon) pp_separate_with_semicolon (cxx_pp); @@ -1275,13 +1275,13 @@ dump_template_decl (tree t, int flags) } /* find_typenames looks through the type of the function template T - and returns a VEC containing any typedefs, decltypes or TYPENAME_TYPEs + and returns a vec containing any typedefs, decltypes or TYPENAME_TYPEs it finds. */ struct find_typenames_t { struct pointer_set_t *p_set; - VEC (tree,gc) *typenames; + vec<tree, va_gc> *typenames; }; static tree @@ -1299,7 +1299,7 @@ find_typenames_r (tree *tp, int * /*walk_subtrees*/, void *data) mv = TYPE_MAIN_VARIANT (*tp); if (mv && (mv == *tp || !pointer_set_insert (d->p_set, mv))) - VEC_safe_push (tree, gc, d->typenames, mv); + vec_safe_push (d->typenames, mv); /* Search into class template arguments, which cp_walk_subtrees doesn't do. */ @@ -1310,7 +1310,7 @@ find_typenames_r (tree *tp, int * /*walk_subtrees*/, void *data) return NULL_TREE; } -static VEC(tree,gc) * +static vec<tree, va_gc> * find_typenames (tree t) { struct find_typenames_t ft; @@ -1338,7 +1338,7 @@ dump_function_decl (tree t, int flags) int show_return = flags & TFF_RETURN_TYPE || flags & TFF_DECL_SPECIFIERS; int do_outer_scope = ! (flags & TFF_UNQUALIFIED_NAME); tree exceptions; - VEC(tree,gc) *typenames = NULL; + vec<tree, va_gc> *typenames = NULL; if (DECL_NAME (t) && LAMBDA_FUNCTION_P (t)) { @@ -1737,7 +1737,7 @@ dump_expr_list (tree l, int flags) /* Print out a vector of initializers (subr of dump_expr). */ static void -dump_expr_init_vec (VEC(constructor_elt,gc) *v, int flags) +dump_expr_init_vec (vec<constructor_elt, va_gc> *v, int flags) { unsigned HOST_WIDE_INT idx; tree value; @@ -1745,7 +1745,7 @@ dump_expr_init_vec (VEC(constructor_elt,gc) *v, int flags) FOR_EACH_CONSTRUCTOR_VALUE (v, idx, value) { dump_expr (value, flags | TFF_EXPR_IN_PARENS); - if (idx != VEC_length (constructor_elt, v) - 1) + if (idx != v->length () - 1) pp_separate_with_comma (cxx_pp); } } @@ -3208,11 +3208,11 @@ print_instantiation_context (void) void maybe_print_constexpr_context (diagnostic_context *context) { - VEC(tree,heap) *call_stack = cx_error_context (); + vec<tree> call_stack = cx_error_context (); unsigned ix; tree t; - FOR_EACH_VEC_ELT (tree, call_stack, ix, t) + FOR_EACH_VEC_ELT (call_stack, ix, t) { expanded_location xloc = expand_location (EXPR_LOCATION (t)); const char *s = expr_as_string (t, 0); diff --git a/gcc/cp/except.c b/gcc/cp/except.c index ad49211..cbb0235 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -824,7 +824,7 @@ build_throw (tree exp) if (CLASS_TYPE_P (temp_type)) { int flags = LOOKUP_NORMAL | LOOKUP_ONLYCONVERTING; - VEC(tree,gc) *exp_vec; + vec<tree, va_gc> *exp_vec; /* Under C++0x [12.8/16 class.copy], a thrown lvalue is sometimes treated as an rvalue for the purposes of overload resolution @@ -1176,9 +1176,7 @@ typedef struct GTY(()) pending_noexcept { tree fn; location_t loc; } pending_noexcept; -DEF_VEC_O(pending_noexcept); -DEF_VEC_ALLOC_O(pending_noexcept,gc); -static GTY(()) VEC(pending_noexcept,gc) *pending_noexcept_checks; +static GTY(()) vec<pending_noexcept, va_gc> *pending_noexcept_checks; /* FN is a FUNCTION_DECL that caused a noexcept-expr to be false. Warn if it can't throw. */ @@ -1204,7 +1202,7 @@ perform_deferred_noexcept_checks (void) int i; pending_noexcept *p; location_t saved_loc = input_location; - FOR_EACH_VEC_ELT (pending_noexcept, pending_noexcept_checks, i, p) + FOR_EACH_VEC_SAFE_ELT (pending_noexcept_checks, i, p) { input_location = p->loc; maybe_noexcept_warning (p->fn); @@ -1248,7 +1246,7 @@ expr_noexcept_p (tree expr, tsubst_flags_t complain) { /* Not defined yet; check again at EOF. */ pending_noexcept p = {fn, input_location}; - VEC_safe_push (pending_noexcept, gc, pending_noexcept_checks, p); + vec_safe_push (pending_noexcept_checks, p); } else maybe_noexcept_warning (fn); diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 9f886c0..fea50b5 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -184,7 +184,7 @@ build_zero_init_1 (tree type, tree nelts, bool static_storage_p, else if (CLASS_TYPE_P (type)) { tree field; - VEC(constructor_elt,gc) *v = NULL; + vec<constructor_elt, va_gc> *v = NULL; /* Iterate over the fields, building initializations. */ for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field)) @@ -233,7 +233,7 @@ build_zero_init_1 (tree type, tree nelts, bool static_storage_p, else if (TREE_CODE (type) == ARRAY_TYPE) { tree max_index; - VEC(constructor_elt,gc) *v = NULL; + vec<constructor_elt, va_gc> *v = NULL; /* Iterate over the array elements, building initializations. */ if (nelts) @@ -255,7 +255,7 @@ build_zero_init_1 (tree type, tree nelts, bool static_storage_p, { constructor_elt ce; - v = VEC_alloc (constructor_elt, gc, 1); + vec_alloc (v, 1); /* If this is a one element array, we just use a regular init. */ if (tree_int_cst_equal (size_zero_node, max_index)) @@ -267,7 +267,7 @@ build_zero_init_1 (tree type, tree nelts, bool static_storage_p, ce.value = build_zero_init_1 (TREE_TYPE (type), /*nelts=*/NULL_TREE, static_storage_p, NULL_TREE); - VEC_quick_push (constructor_elt, v, ce); + v->quick_push (ce); } /* Build a constructor to contain the initializations. */ @@ -391,7 +391,7 @@ build_value_init_noctor (tree type, tsubst_flags_t complain) if (TREE_CODE (type) != UNION_TYPE) { tree field; - VEC(constructor_elt,gc) *v = NULL; + vec<constructor_elt, va_gc> *v = NULL; /* Iterate over the fields, building initializations. */ for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field)) @@ -428,7 +428,7 @@ build_value_init_noctor (tree type, tsubst_flags_t complain) } else if (TREE_CODE (type) == ARRAY_TYPE) { - VEC(constructor_elt,gc) *v = NULL; + vec<constructor_elt, va_gc> *v = NULL; /* Iterate over the array elements, building initializations. */ tree max_index = array_type_nelts (type); @@ -450,7 +450,7 @@ build_value_init_noctor (tree type, tsubst_flags_t complain) { constructor_elt ce; - v = VEC_alloc (constructor_elt, gc, 1); + vec_alloc (v, 1); /* If this is a one element array, we just use a regular init. */ if (tree_int_cst_equal (size_zero_node, max_index)) @@ -459,7 +459,7 @@ build_value_init_noctor (tree type, tsubst_flags_t complain) ce.index = build2 (RANGE_EXPR, sizetype, size_zero_node, max_index); ce.value = build_value_init (TREE_TYPE (type), complain); - VEC_quick_push (constructor_elt, v, ce); + v->quick_push (ce); if (ce.value == error_mark_node) return error_mark_node; @@ -628,7 +628,7 @@ perform_member_init (tree member, tree init) reference member in a constructor’s ctor-initializer (12.6.2) persists until the constructor exits." */ unsigned i; tree t; - VEC(tree,gc) *cleanups = make_tree_vector (); + vec<tree, va_gc> *cleanups = make_tree_vector (); if (TREE_CODE (init) == TREE_LIST) init = build_x_compound_expr_from_list (init, ELK_MEM_INIT, tf_warning_or_error); @@ -645,7 +645,7 @@ perform_member_init (tree member, tree init) init = build_vec_init_expr (type, init, tf_warning_or_error); init = build2 (INIT_EXPR, type, decl, init); finish_expr_stmt (init); - FOR_EACH_VEC_ELT (tree, cleanups, i, t) + FOR_EACH_VEC_ELT (*cleanups, i, t) push_cleanup (decl, t, false); release_tree_vector (cleanups); } @@ -802,7 +802,7 @@ sort_mem_initializers (tree t, tree mem_inits) tree base, binfo, base_binfo; tree sorted_inits; tree next_subobject; - VEC(tree,gc) *vbases; + vec<tree, va_gc> *vbases; int i; int uses_unions_p = 0; @@ -814,7 +814,7 @@ sort_mem_initializers (tree t, tree mem_inits) /* Process the virtual bases. */ for (vbases = CLASSTYPE_VBASECLASSES (t), i = 0; - VEC_iterate (tree, vbases, i, base); i++) + vec_safe_iterate (vbases, i, &base); i++) sorted_inits = tree_cons (base, NULL_TREE, sorted_inits); /* Process the direct bases. */ @@ -1545,7 +1545,7 @@ expand_default_init (tree binfo, tree true_exp, tree exp, tree init, int flags, followed by initialization by X. If neither of these work out, then look hard. */ tree rval; - VEC(tree,gc) *parms; + vec<tree, va_gc> *parms; /* If we have direct-initialization from an initializer list, pull it out of the TREE_LIST so the code below can see it. */ @@ -1627,7 +1627,7 @@ expand_default_init (tree binfo, tree true_exp, tree exp, tree init, int flags, { parms = make_tree_vector (); for (; init != NULL_TREE; init = TREE_CHAIN (init)) - VEC_safe_push (tree, gc, parms, TREE_VALUE (init)); + vec_safe_push (parms, TREE_VALUE (init)); } else parms = make_tree_vector_single (init); @@ -1641,11 +1641,11 @@ expand_default_init (tree binfo, tree true_exp, tree exp, tree init, int flags, tree elt; unsigned i; /* Unshare the arguments for the second call. */ - VEC(tree,gc) *parms2 = make_tree_vector (); - FOR_EACH_VEC_ELT (tree, parms, i, elt) + vec<tree, va_gc> *parms2 = make_tree_vector (); + FOR_EACH_VEC_SAFE_ELT (parms, i, elt) { elt = break_out_target_exprs (elt); - VEC_safe_push (tree, gc, parms2, elt); + vec_safe_push (parms2, elt); } complete = build_special_member_call (exp, complete_ctor_identifier, &parms2, binfo, flags, @@ -1730,7 +1730,7 @@ expand_aggr_init_1 (tree binfo, tree true_exp, tree exp, tree init, int flags, if (init && TREE_CODE (exp) == VAR_DECL && COMPOUND_LITERAL_P (init)) { - VEC(tree,gc)* cleanups = NULL; + vec<tree, va_gc> *cleanups = NULL; /* If store_init_value returns NULL_TREE, the INIT has been recorded as the DECL_INITIAL for EXP. That means there's nothing more we have to do. */ @@ -2062,8 +2062,8 @@ build_builtin_delete_call (tree addr) creates and returns a NEW_EXPR. */ static tree -build_raw_new_expr (VEC(tree,gc) *placement, tree type, tree nelts, - VEC(tree,gc) *init, int use_global_new) +build_raw_new_expr (vec<tree, va_gc> *placement, tree type, tree nelts, + vec<tree, va_gc> *init, int use_global_new) { tree init_list; tree new_expr; @@ -2074,7 +2074,7 @@ build_raw_new_expr (VEC(tree,gc) *placement, tree type, tree nelts, int" from an empty initializer "new int()". */ if (init == NULL) init_list = NULL_TREE; - else if (VEC_empty (tree, init)) + else if (init->is_empty ()) init_list = void_zero_node; else init_list = build_tree_list_vec (init); @@ -2165,8 +2165,8 @@ diagnose_uninitialized_cst_or_ref_member (tree type, bool using_new, bool compla build_raw_new_expr. This may change PLACEMENT and INIT. */ static tree -build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts, - VEC(tree,gc) **init, bool globally_qualified_p, +build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts, + vec<tree, va_gc> **init, bool globally_qualified_p, tsubst_flags_t complain) { tree size, rval; @@ -2397,13 +2397,12 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts, reference, prepare to capture it in a temporary variable. Do this now, since PLACEMENT will change in the calls below. */ placement_first = NULL_TREE; - if (VEC_length (tree, *placement) == 1 - && (TREE_CODE (TREE_TYPE (VEC_index (tree, *placement, 0))) - == POINTER_TYPE)) - placement_first = VEC_index (tree, *placement, 0); + if (vec_safe_length (*placement) == 1 + && (TREE_CODE (TREE_TYPE ((**placement)[0])) == POINTER_TYPE)) + placement_first = (**placement)[0]; /* Allocate the object. */ - if (VEC_empty (tree, *placement) && TYPE_FOR_JAVA (elt_type)) + if (vec_safe_is_empty (*placement) && TYPE_FOR_JAVA (elt_type)) { tree class_addr; tree class_decl = build_java_class_ref (elt_type); @@ -2466,7 +2465,7 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts, size = fold_build3 (COND_EXPR, sizetype, outer_nelts_check, size, TYPE_MAX_VALUE (sizetype)); /* Create the argument list. */ - VEC_safe_insert (tree, gc, *placement, 0, size); + vec_safe_insert (*placement, 0, size); /* Do name-lookup to find the appropriate operator. */ fns = lookup_fnfields (elt_type, fnname, /*protect=*/2); if (fns == NULL_TREE) @@ -2651,7 +2650,7 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts, bool stable; bool explicit_value_init_p = false; - if (*init != NULL && VEC_empty (tree, *init)) + if (*init != NULL && (*init)->is_empty ()) { *init = NULL; explicit_value_init_p = true; @@ -2675,11 +2674,11 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts, else if (array_p) { tree vecinit = NULL_TREE; - if (*init && VEC_length (tree, *init) == 1 - && BRACE_ENCLOSED_INITIALIZER_P (VEC_index (tree, *init, 0)) - && CONSTRUCTOR_IS_DIRECT_INIT (VEC_index (tree, *init, 0))) + if (vec_safe_length (*init) == 1 + && BRACE_ENCLOSED_INITIALIZER_P ((**init)[0]) + && CONSTRUCTOR_IS_DIRECT_INIT ((**init)[0])) { - vecinit = VEC_index (tree, *init, 0); + vecinit = (**init)[0]; if (CONSTRUCTOR_NELTS (vecinit) == 0) /* List-value-initialization, leave it alone. */; else @@ -2891,25 +2890,25 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts, rather than just "new". This may change PLACEMENT and INIT. */ tree -build_new (VEC(tree,gc) **placement, tree type, tree nelts, - VEC(tree,gc) **init, int use_global_new, tsubst_flags_t complain) +build_new (vec<tree, va_gc> **placement, tree type, tree nelts, + vec<tree, va_gc> **init, int use_global_new, tsubst_flags_t complain) { tree rval; - VEC(tree,gc) *orig_placement = NULL; + vec<tree, va_gc> *orig_placement = NULL; tree orig_nelts = NULL_TREE; - VEC(tree,gc) *orig_init = NULL; + vec<tree, va_gc> *orig_init = NULL; if (type == error_mark_node) return error_mark_node; - if (nelts == NULL_TREE && VEC_length (tree, *init) == 1 + if (nelts == NULL_TREE && vec_safe_length (*init) == 1 /* Don't do auto deduction where it might affect mangling. */ && (!processing_template_decl || at_function_scope_p ())) { tree auto_node = type_uses_auto (type); if (auto_node) { - tree d_init = VEC_index (tree, *init, 0); + tree d_init = (**init)[0]; d_init = resolve_nondeduced_context (d_init); type = do_auto_deduction (type, d_init, auto_node); } @@ -3308,7 +3307,7 @@ build_vec_init (tree base, tree maxindex, tree init, && ((TREE_CODE (init) == CONSTRUCTOR /* Don't do this if the CONSTRUCTOR might contain something that might throw and require us to clean up. */ - && (VEC_empty (constructor_elt, CONSTRUCTOR_ELTS (init)) + && (vec_safe_is_empty (CONSTRUCTOR_ELTS (init)) || ! TYPE_HAS_NONTRIVIAL_DESTRUCTOR (inner_elt_type))) || from_array)) { @@ -3428,11 +3427,11 @@ build_vec_init (tree base, tree maxindex, tree init, initialization of any elements with constant initializers even if some are non-constant. */ bool do_static_init = (DECL_P (obase) && TREE_STATIC (obase)); - VEC(constructor_elt,gc) *new_vec; + vec<constructor_elt, va_gc> *new_vec; from_array = 0; if (try_const) - new_vec = VEC_alloc (constructor_elt, gc, CONSTRUCTOR_NELTS (init)); + vec_alloc (new_vec, CONSTRUCTOR_NELTS (init)); else new_vec = NULL; @@ -3506,7 +3505,7 @@ build_vec_init (tree base, tree maxindex, tree init, else if (do_static_init && saw_const) DECL_INITIAL (obase) = build_constructor (atype, new_vec); else - VEC_free (constructor_elt, gc, new_vec); + vec_free (new_vec); } /* Clear out INIT so that we don't get confused below. */ @@ -3937,7 +3936,7 @@ push_base_cleanups (void) int i; tree member; tree expr; - VEC(tree,gc) *vbases; + vec<tree, va_gc> *vbases; /* Run destructors for all virtual baseclasses. */ if (CLASSTYPE_VBASECLASSES (current_class_type)) @@ -3950,7 +3949,7 @@ push_base_cleanups (void) /* The CLASSTYPE_VBASECLASSES vector is in initialization order, which is also the right order for pushing cleanups. */ for (vbases = CLASSTYPE_VBASECLASSES (current_class_type), i = 0; - VEC_iterate (tree, vbases, i, base_binfo); i++) + vec_safe_iterate (vbases, i, &base_binfo); i++) { if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (BINFO_TYPE (base_binfo))) { diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 54a4c9c..2b1d397 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -91,7 +91,7 @@ along with GCC; see the file COPYING3. If not see typedef struct GTY(()) globals { /* An array of the current substitution candidates, in the order we've seen them. */ - VEC(tree,gc) *substitutions; + vec<tree, va_gc> *substitutions; /* The entity that is being mangled. */ tree GTY ((skip)) entity; @@ -311,7 +311,7 @@ dump_substitution_candidates (void) tree el; fprintf (stderr, " ++ substitutions "); - FOR_EACH_VEC_ELT (tree, G.substitutions, i, el) + FOR_EACH_VEC_ELT (*G.substitutions, i, el) { const char *name = "???"; @@ -391,7 +391,7 @@ add_substitution (tree node) int i; tree candidate; - FOR_EACH_VEC_ELT (tree, G.substitutions, i, candidate) + FOR_EACH_VEC_SAFE_ELT (G.substitutions, i, candidate) { gcc_assert (!(DECL_P (node) && node == candidate)); gcc_assert (!(TYPE_P (node) && TYPE_P (candidate) @@ -401,7 +401,7 @@ add_substitution (tree node) #endif /* ENABLE_CHECKING */ /* Put the decl onto the varray of substitution candidates. */ - VEC_safe_push (tree, gc, G.substitutions, node); + vec_safe_push (G.substitutions, node); if (DEBUG_MANGLE) dump_substitution_candidates (); @@ -504,7 +504,7 @@ static int find_substitution (tree node) { int i; - const int size = VEC_length (tree, G.substitutions); + const int size = vec_safe_length (G.substitutions); tree decl; tree type; @@ -612,7 +612,7 @@ find_substitution (tree node) operation. */ for (i = 0; i < size; ++i) { - tree candidate = VEC_index (tree, G.substitutions, i); + tree candidate = (*G.substitutions)[i]; /* NODE is a matched to a candidate if it's the same decl node or if it's the same type. */ if (decl == candidate @@ -1322,18 +1322,18 @@ write_abi_tags (tree tags) tags = TREE_VALUE (tags); - VEC(tree,gc)* vec = make_tree_vector(); + vec<tree, va_gc> * vec = make_tree_vector(); for (tree t = tags; t; t = TREE_CHAIN (t)) { tree str = TREE_VALUE (t); - VEC_safe_push (tree, gc, vec, str); + vec_safe_push (vec, str); } - VEC_qsort (tree, vec, tree_string_cmp); + vec->qsort (tree_string_cmp); unsigned i; tree str; - FOR_EACH_VEC_ELT (tree, vec, i, str) + FOR_EACH_VEC_ELT (*vec, i, str) { write_string ("B"); write_unsigned_number (TREE_STRING_LENGTH (str) - 1); @@ -1699,7 +1699,7 @@ local_class_index (tree entity) tree ctx = TYPE_CONTEXT (entity); for (ix = 0; ; ix++) { - tree type = VEC_index (tree, local_classes, ix); + tree type = (*local_classes)[ix]; if (type == entity) return discriminator; if (TYPE_CONTEXT (type) == ctx @@ -2801,7 +2801,7 @@ write_expression (tree expr) } else if (code == CONSTRUCTOR) { - VEC(constructor_elt,gc)* elts = CONSTRUCTOR_ELTS (expr); + vec<constructor_elt, va_gc> *elts = CONSTRUCTOR_ELTS (expr); unsigned i; tree val; if (BRACE_ENCLOSED_INITIALIZER_P (expr)) @@ -3320,7 +3320,7 @@ finish_mangling_internal (const bool warn) G.entity); /* Clear all the substitutions. */ - VEC_truncate (tree, G.substitutions, 0); + vec_safe_truncate (G.substitutions, 0); /* Null-terminate the string. */ write_char ('\0'); @@ -3354,7 +3354,7 @@ init_mangle (void) { gcc_obstack_init (&name_obstack); name_base = obstack_alloc (&name_obstack, 0); - G.substitutions = NULL; + vec_alloc (G.substitutions, 0); /* Cache these identifiers for quick comparison when checking for standard substitutions. */ diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 8a7d7cb..6458032 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -550,7 +550,7 @@ do_build_copy_constructor (tree fndecl) int i; tree binfo, base_binfo; tree init; - VEC(tree,gc) *vbases; + vec<tree, va_gc> *vbases; /* Initialize all the base-classes with the parameter converted to their type so that we get their copy constructor and not @@ -558,7 +558,7 @@ do_build_copy_constructor (tree fndecl) deal with the binfo's directly as a direct base might be inaccessible due to ambiguity. */ for (vbases = CLASSTYPE_VBASECLASSES (current_class_type), i = 0; - VEC_iterate (tree, vbases, i, binfo); i++) + vec_safe_iterate (vbases, i, &binfo); i++) { member_init_list = add_one_base_init (binfo, parm, move_p, inh, member_init_list); @@ -655,7 +655,7 @@ do_build_copy_assign (tree fndecl) BINFO_BASE_ITERATE (binfo, i, base_binfo); i++) { tree converted_parm; - VEC(tree,gc) *parmvec; + vec<tree, va_gc> *parmvec; /* We must convert PARM directly to the base class explicitly since the base class may be ambiguous. */ @@ -852,7 +852,7 @@ locate_fn_flags (tree type, tree name, tree argtype, int flags, tsubst_flags_t complain) { tree ob, fn, fns, binfo, rval; - VEC(tree,gc) *args; + vec<tree, va_gc> *args; if (TYPE_P (type)) binfo = TYPE_BINFO (type); @@ -875,13 +875,13 @@ locate_fn_flags (tree type, tree name, tree argtype, int flags, if (TREE_CODE (type) != REFERENCE_TYPE) type = cp_build_reference_type (type, /*rval*/true); tree arg = build_stub_object (type); - VEC_safe_push (tree, gc, args, arg); + vec_safe_push (args, arg); } } else { tree arg = build_stub_object (argtype); - VEC_quick_push (tree, args, arg); + args->quick_push (arg); } } @@ -1157,7 +1157,7 @@ synthesized_method_walk (tree ctype, special_function_kind sfk, bool const_p, { tree binfo, base_binfo, scope, fnname, rval, argtype; bool move_p, copy_arg_p, assign_p, expected_trivial, check_vdtor; - VEC(tree,gc) *vbases; + vec<tree, va_gc> *vbases; int i, quals, flags; tsubst_flags_t complain; bool ctor_p; @@ -1351,7 +1351,7 @@ synthesized_method_walk (tree ctype, special_function_kind sfk, bool const_p, { if (constexpr_p) *constexpr_p = false; - FOR_EACH_VEC_ELT (tree, vbases, i, base_binfo) + FOR_EACH_VEC_ELT (*vbases, i, base_binfo) { tree basetype = BINFO_TYPE (base_binfo); if (copy_arg_p) diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index f010560..5abebe3 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -320,7 +320,7 @@ new_class_binding (tree name, tree value, tree type, cp_binding_level *scope) { cp_class_binding cb = {cxx_binding_make (value, type), name}; cxx_binding *binding = cb.base; - VEC_safe_push (cp_class_binding, gc, scope->class_shadowed, cb); + vec_safe_push (scope->class_shadowed, cb); binding->scope = scope; return binding; } @@ -597,7 +597,7 @@ add_decl_to_level (tree decl, cp_binding_level *b) && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))) || (TREE_CODE (decl) == FUNCTION_DECL && (!TREE_PUBLIC (decl) || DECL_DECLARED_INLINE_P (decl)))) - VEC_safe_push (tree, gc, b->static_decls, decl); + vec_safe_push (b->static_decls, decl); } } @@ -1506,11 +1506,9 @@ begin_scope (scope_kind kind, tree entity) case sk_namespace: NAMESPACE_LEVEL (entity) = scope; - scope->static_decls = - VEC_alloc (tree, gc, - DECL_NAME (entity) == std_identifier - || DECL_NAME (entity) == global_scope_name - ? 200 : 10); + vec_alloc (scope->static_decls, + (DECL_NAME (entity) == std_identifier + || DECL_NAME (entity) == global_scope_name) ? 200 : 10); break; default: @@ -1781,12 +1779,12 @@ print_binding_level (cp_binding_level* lvl) if (i) fprintf (stderr, "\n"); } - if (VEC_length (cp_class_binding, lvl->class_shadowed)) + if (vec_safe_length (lvl->class_shadowed)) { size_t i; cp_class_binding *b; fprintf (stderr, " class-shadowed:"); - FOR_EACH_VEC_ELT (cp_class_binding, lvl->class_shadowed, i, b) + FOR_EACH_VEC_ELT (*lvl->class_shadowed, i, b) fprintf (stderr, " %s ", IDENTIFIER_POINTER (b->identifier)); fprintf (stderr, "\n"); } @@ -2836,7 +2834,7 @@ poplevel_class (void) /* Remove the bindings for all of the class-level declarations. */ if (level->class_shadowed) { - FOR_EACH_VEC_ELT (cp_class_binding, level->class_shadowed, i, cb) + FOR_EACH_VEC_ELT (*level->class_shadowed, i, cb) { IDENTIFIER_BINDING (cb->identifier) = cb->base->previous; cxx_binding_free (cb->base); @@ -3468,8 +3466,8 @@ current_decl_namespace (void) { tree result; /* If we have been pushed into a different namespace, use it. */ - if (!VEC_empty (tree, decl_namespace_list)) - return VEC_last (tree, decl_namespace_list); + if (!vec_safe_is_empty (decl_namespace_list)) + return decl_namespace_list->last (); if (current_class_type) result = decl_namespace_context (current_class_type); @@ -3674,7 +3672,7 @@ push_decl_namespace (tree decl) { if (TREE_CODE (decl) != NAMESPACE_DECL) decl = decl_namespace_context (decl); - VEC_safe_push (tree, gc, decl_namespace_list, ORIGINAL_NAMESPACE (decl)); + vec_safe_push (decl_namespace_list, ORIGINAL_NAMESPACE (decl)); } /* [namespace.memdef]/2 */ @@ -3682,7 +3680,7 @@ push_decl_namespace (tree decl) void pop_decl_namespace (void) { - VEC_pop (tree, decl_namespace_list); + decl_namespace_list->pop (); } /* Return the namespace that is the common ancestor @@ -4224,19 +4222,19 @@ remove_hidden_names (tree fns) void suggest_alternatives_for (location_t location, tree name) { - VEC(tree,heap) *candidates = NULL; - VEC(tree,heap) *namespaces_to_search = NULL; + vec<tree> candidates = vec<tree>(); + vec<tree> namespaces_to_search = vec<tree>(); int max_to_search = PARAM_VALUE (CXX_MAX_NAMESPACES_FOR_DIAGNOSTIC_HELP); int n_searched = 0; tree t; unsigned ix; - VEC_safe_push (tree, heap, namespaces_to_search, global_namespace); + namespaces_to_search.safe_push (global_namespace); - while (!VEC_empty (tree, namespaces_to_search) + while (!namespaces_to_search.is_empty () && n_searched < max_to_search) { - tree scope = VEC_pop (tree, namespaces_to_search); + tree scope = namespaces_to_search.pop (); struct scope_binding binding = EMPTY_SCOPE_BINDING; cp_binding_level *level = NAMESPACE_LEVEL (scope); @@ -4246,11 +4244,11 @@ suggest_alternatives_for (location_t location, tree name) n_searched++; if (binding.value) - VEC_safe_push (tree, heap, candidates, binding.value); + candidates.safe_push (binding.value); /* Add child namespaces. */ for (t = level->namespaces; t; t = DECL_CHAIN (t)) - VEC_safe_push (tree, heap, namespaces_to_search, t); + namespaces_to_search.safe_push (t); } /* If we stopped before we could examine all namespaces, inform the @@ -4258,25 +4256,25 @@ suggest_alternatives_for (location_t location, tree name) might be more candidates further down that we weren't able to find. */ if (n_searched >= max_to_search - && !VEC_empty (tree, namespaces_to_search)) + && !namespaces_to_search.is_empty ()) inform (location, "maximum limit of %d namespaces searched for %qE", max_to_search, name); - VEC_free (tree, heap, namespaces_to_search); + namespaces_to_search.release (); /* Nothing useful to report. */ - if (VEC_empty (tree, candidates)) + if (candidates.is_empty ()) return; - inform_n (location, VEC_length (tree, candidates), + inform_n (location, candidates.length (), "suggested alternative:", "suggested alternatives:"); - FOR_EACH_VEC_ELT (tree, candidates, ix, t) + FOR_EACH_VEC_ELT (candidates, ix, t) inform (location_of (t), " %qE", t); - VEC_free (tree, heap, candidates); + candidates.release (); } /* Unscoped lookup of a global: iterate over current namespaces, @@ -4408,11 +4406,11 @@ lookup_using_namespace (tree name, struct scope_binding *val, /* Returns true iff VEC contains TARGET. */ static bool -tree_vec_contains (VEC(tree,gc)* vec, tree target) +tree_vec_contains (vec<tree, va_gc> *vec, tree target) { unsigned int i; tree elt; - FOR_EACH_VEC_ELT (tree,vec,i,elt) + FOR_EACH_VEC_SAFE_ELT (vec,i,elt) if (elt == target) return true; return false; @@ -4428,12 +4426,12 @@ qualified_lookup_using_namespace (tree name, tree scope, struct scope_binding *result, int flags) { /* Maintain a list of namespaces visited... */ - VEC(tree,gc) *seen = NULL; - VEC(tree,gc) *seen_inline = NULL; + vec<tree, va_gc> *seen = NULL; + vec<tree, va_gc> *seen_inline = NULL; /* ... and a list of namespace yet to see. */ - VEC(tree,gc) *todo = NULL; - VEC(tree,gc) *todo_maybe = NULL; - VEC(tree,gc) *todo_inline = NULL; + vec<tree, va_gc> *todo = NULL; + vec<tree, va_gc> *todo_maybe = NULL; + vec<tree, va_gc> *todo_inline = NULL; tree usings; timevar_start (TV_NAME_LOOKUP); /* Look through namespace aliases. */ @@ -4443,26 +4441,26 @@ qualified_lookup_using_namespace (tree name, tree scope, namespaces. For each used namespace, look through its inline namespace set for any bindings and usings. If no bindings are found, add any usings seen to the set of used namespaces. */ - VEC_safe_push (tree, gc, todo, scope); + vec_safe_push (todo, scope); - while (VEC_length (tree, todo)) + while (todo->length ()) { bool found_here; - scope = VEC_pop (tree, todo); + scope = todo->pop (); if (tree_vec_contains (seen, scope)) continue; - VEC_safe_push (tree, gc, seen, scope); - VEC_safe_push (tree, gc, todo_inline, scope); + vec_safe_push (seen, scope); + vec_safe_push (todo_inline, scope); found_here = false; - while (VEC_length (tree, todo_inline)) + while (todo_inline->length ()) { cxx_binding *binding; - scope = VEC_pop (tree, todo_inline); + scope = todo_inline->pop (); if (tree_vec_contains (seen_inline, scope)) continue; - VEC_safe_push (tree, gc, seen_inline, scope); + vec_safe_push (seen_inline, scope); binding = cp_binding_level_find_binding_for_name (NAMESPACE_LEVEL (scope), name); @@ -4477,23 +4475,23 @@ qualified_lookup_using_namespace (tree name, tree scope, if (!TREE_INDIRECT_USING (usings)) { if (is_associated_namespace (scope, TREE_PURPOSE (usings))) - VEC_safe_push (tree, gc, todo_inline, TREE_PURPOSE (usings)); + vec_safe_push (todo_inline, TREE_PURPOSE (usings)); else - VEC_safe_push (tree, gc, todo_maybe, TREE_PURPOSE (usings)); + vec_safe_push (todo_maybe, TREE_PURPOSE (usings)); } } if (found_here) - VEC_truncate (tree, todo_maybe, 0); + vec_safe_truncate (todo_maybe, 0); else - while (VEC_length (tree, todo_maybe)) - VEC_safe_push (tree, gc, todo, VEC_pop (tree, todo_maybe)); - } - VEC_free (tree,gc,todo); - VEC_free (tree,gc,todo_maybe); - VEC_free (tree,gc,todo_inline); - VEC_free (tree,gc,seen); - VEC_free (tree,gc,seen_inline); + while (vec_safe_length (todo_maybe)) + vec_safe_push (todo, todo_maybe->pop ()); + } + vec_free (todo); + vec_free (todo_maybe); + vec_free (todo_inline); + vec_free (seen); + vec_free (seen_inline); timevar_stop (TV_NAME_LOOKUP); return result->value != error_mark_node; } @@ -4791,7 +4789,7 @@ lookup_name_nonclass (tree name) } tree -lookup_function_nonclass (tree name, VEC(tree,gc) *args, bool block_p) +lookup_function_nonclass (tree name, vec<tree, va_gc> *args, bool block_p) { return lookup_arg_dependent (name, @@ -5035,16 +5033,16 @@ lookup_type_current_level (tree name) struct arg_lookup { tree name; - VEC(tree,gc) *args; - VEC(tree,gc) *namespaces; - VEC(tree,gc) *classes; + vec<tree, va_gc> *args; + vec<tree, va_gc> *namespaces; + vec<tree, va_gc> *classes; tree functions; struct pointer_set_t *fn_set; }; static bool arg_assoc (struct arg_lookup*, tree); static bool arg_assoc_args (struct arg_lookup*, tree); -static bool arg_assoc_args_vec (struct arg_lookup*, VEC(tree,gc) *); +static bool arg_assoc_args_vec (struct arg_lookup*, vec<tree, va_gc> *); static bool arg_assoc_type (struct arg_lookup*, tree); static bool add_function (struct arg_lookup *, tree); static bool arg_assoc_namespace (struct arg_lookup *, tree); @@ -5085,8 +5083,8 @@ add_function (struct arg_lookup *k, tree fn) bool is_associated_namespace (tree current, tree scope) { - VEC(tree,gc) *seen = make_tree_vector (); - VEC(tree,gc) *todo = make_tree_vector (); + vec<tree, va_gc> *seen = make_tree_vector (); + vec<tree, va_gc> *todo = make_tree_vector (); tree t; bool ret; @@ -5097,14 +5095,14 @@ is_associated_namespace (tree current, tree scope) ret = true; break; } - VEC_safe_push (tree, gc, seen, scope); + vec_safe_push (seen, scope); for (t = DECL_NAMESPACE_ASSOCIATIONS (scope); t; t = TREE_CHAIN (t)) if (!vec_member (TREE_PURPOSE (t), seen)) - VEC_safe_push (tree, gc, todo, TREE_PURPOSE (t)); - if (!VEC_empty (tree, todo)) + vec_safe_push (todo, TREE_PURPOSE (t)); + if (!todo->is_empty ()) { - scope = VEC_last (tree, todo); - VEC_pop (tree, todo); + scope = todo->last (); + todo->pop (); } else { @@ -5129,7 +5127,7 @@ arg_assoc_namespace (struct arg_lookup *k, tree scope) if (vec_member (scope, k->namespaces)) return false; - VEC_safe_push (tree, gc, k->namespaces, scope); + vec_safe_push (k->namespaces, scope); /* Check out our super-users. */ for (value = DECL_NAMESPACE_ASSOCIATIONS (scope); value; @@ -5312,7 +5310,7 @@ arg_assoc_class (struct arg_lookup *k, tree type) if (vec_member (type, k->classes)) return false; - VEC_safe_push (tree, gc, k->classes, type); + vec_safe_push (k->classes, type); if (TYPE_CLASS_SCOPE_P (type) && arg_assoc_class_only (k, TYPE_CONTEXT (type))) @@ -5422,12 +5420,12 @@ arg_assoc_args (struct arg_lookup *k, tree args) on error. */ static bool -arg_assoc_args_vec (struct arg_lookup *k, VEC(tree,gc) *args) +arg_assoc_args_vec (struct arg_lookup *k, vec<tree, va_gc> *args) { unsigned int ix; tree arg; - FOR_EACH_VEC_ELT (tree, args, ix, arg) + FOR_EACH_VEC_SAFE_ELT (args, ix, arg) if (arg_assoc (k, arg)) return true; return false; @@ -5495,7 +5493,7 @@ arg_assoc (struct arg_lookup *k, tree n) are the functions found in normal lookup. */ static tree -lookup_arg_dependent_1 (tree name, tree fns, VEC(tree,gc) *args, +lookup_arg_dependent_1 (tree name, tree fns, vec<tree, va_gc> *args, bool include_std) { struct arg_lookup k; @@ -5560,7 +5558,7 @@ lookup_arg_dependent_1 (tree name, tree fns, VEC(tree,gc) *args, /* Wrapper for lookup_arg_dependent_1. */ tree -lookup_arg_dependent (tree name, tree fns, VEC(tree,gc) *args, +lookup_arg_dependent (tree name, tree fns, vec<tree, va_gc> *args, bool include_std) { tree ret; @@ -5820,7 +5818,7 @@ pushtag_1 (tree name, tree type, tag_scope scope) add_decl_expr (decl); } else - VEC_safe_push (tree, gc, local_classes, type); + vec_safe_push (local_classes, type); } } if (b->kind == sk_class @@ -5884,7 +5882,7 @@ store_binding_p (tree id) have enough space reserved. */ static void -store_binding (tree id, VEC(cxx_saved_binding,gc) **old_bindings) +store_binding (tree id, vec<cxx_saved_binding, va_gc> **old_bindings) { cxx_saved_binding saved; @@ -5895,14 +5893,14 @@ store_binding (tree id, VEC(cxx_saved_binding,gc) **old_bindings) saved.identifier = id; saved.binding = IDENTIFIER_BINDING (id); saved.real_type_value = REAL_IDENTIFIER_TYPE_VALUE (id); - VEC_quick_push (cxx_saved_binding, *old_bindings, saved); + (*old_bindings)->quick_push (saved); IDENTIFIER_BINDING (id) = NULL; } static void -store_bindings (tree names, VEC(cxx_saved_binding,gc) **old_bindings) +store_bindings (tree names, vec<cxx_saved_binding, va_gc> **old_bindings) { - static VEC(tree,heap) *bindings_need_stored = NULL; + static vec<tree> bindings_need_stored = vec<tree>(); tree t, id; size_t i; @@ -5915,19 +5913,18 @@ store_bindings (tree names, VEC(cxx_saved_binding,gc) **old_bindings) id = DECL_NAME (t); if (store_binding_p (id)) - VEC_safe_push(tree, heap, bindings_need_stored, id); + bindings_need_stored.safe_push (id); } - if (!VEC_empty (tree, bindings_need_stored)) + if (!bindings_need_stored.is_empty ()) { - VEC_reserve_exact (cxx_saved_binding, gc, *old_bindings, - VEC_length (tree, bindings_need_stored)); - for (i = 0; VEC_iterate(tree, bindings_need_stored, i, id); ++i) + vec_safe_reserve_exact (*old_bindings, bindings_need_stored.length ()); + for (i = 0; bindings_need_stored.iterate (i, &id); ++i) { /* We can appearantly have duplicates in NAMES. */ if (store_binding_p (id)) store_binding (id, old_bindings); } - VEC_truncate (tree, bindings_need_stored, 0); + bindings_need_stored.truncate (0); } timevar_cond_stop (TV_NAME_LOOKUP, subtime); } @@ -5936,25 +5933,24 @@ store_bindings (tree names, VEC(cxx_saved_binding,gc) **old_bindings) objects, rather than a TREE_LIST. */ static void -store_class_bindings (VEC(cp_class_binding,gc) *names, - VEC(cxx_saved_binding,gc) **old_bindings) +store_class_bindings (vec<cp_class_binding, va_gc> *names, + vec<cxx_saved_binding, va_gc> **old_bindings) { - static VEC(tree,heap) *bindings_need_stored = NULL; + static vec<tree> bindings_need_stored = vec<tree>(); size_t i; cp_class_binding *cb; bool subtime = timevar_cond_start (TV_NAME_LOOKUP); - for (i = 0; VEC_iterate(cp_class_binding, names, i, cb); ++i) + for (i = 0; vec_safe_iterate (names, i, &cb); ++i) if (store_binding_p (cb->identifier)) - VEC_safe_push (tree, heap, bindings_need_stored, cb->identifier); - if (!VEC_empty (tree, bindings_need_stored)) + bindings_need_stored.safe_push (cb->identifier); + if (!bindings_need_stored.is_empty ()) { tree id; - VEC_reserve_exact (cxx_saved_binding, gc, *old_bindings, - VEC_length (tree, bindings_need_stored)); - for (i = 0; VEC_iterate(tree, bindings_need_stored, i, id); ++i) + vec_safe_reserve_exact (*old_bindings, bindings_need_stored.length ()); + for (i = 0; bindings_need_stored.iterate (i, &id); ++i) store_binding (id, old_bindings); - VEC_truncate (tree, bindings_need_stored, 0); + bindings_need_stored.truncate (0); } timevar_cond_stop (TV_NAME_LOOKUP, subtime); } @@ -6010,7 +6006,7 @@ push_to_top_level (void) SET_IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (t), TREE_VALUE (t)); } - FOR_EACH_VEC_ELT (cxx_saved_binding, s->old_bindings, i, sb) + FOR_EACH_VEC_SAFE_ELT (s->old_bindings, i, sb) IDENTIFIER_MARKED (sb->identifier) = 0; s->prev = scope_chain; @@ -6023,7 +6019,7 @@ push_to_top_level (void) scope_chain = s; current_function_decl = NULL_TREE; - current_lang_base = VEC_alloc (tree, gc, 10); + vec_alloc (current_lang_base, 10); current_lang_name = lang_name_cplusplus; current_namespace = global_namespace; push_class_stack (); @@ -6047,7 +6043,7 @@ pop_from_top_level_1 (void) current_lang_base = 0; scope_chain = s->prev; - FOR_EACH_VEC_ELT (cxx_saved_binding, s->old_bindings, i, saved) + FOR_EACH_VEC_SAFE_ELT (s->old_bindings, i, saved) { tree id = saved->identifier; diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h index a37afdb..540e200 100644 --- a/gcc/cp/name-lookup.h +++ b/gcc/cp/name-lookup.h @@ -86,8 +86,6 @@ typedef struct GTY(()) cxx_saved_binding { tree real_type_value; } cxx_saved_binding; -DEF_VEC_O(cxx_saved_binding); -DEF_VEC_ALLOC_O(cxx_saved_binding,gc); extern tree identifier_type_value (tree); extern void set_identifier_type_value (tree, tree); @@ -147,8 +145,6 @@ typedef struct GTY(()) cp_class_binding { tree identifier; } cp_class_binding; -DEF_VEC_O(cp_class_binding); -DEF_VEC_ALLOC_O(cp_class_binding,gc); typedef struct GTY(()) cp_label_binding { /* The bound LABEL_DECL. */ @@ -157,8 +153,6 @@ typedef struct GTY(()) cp_label_binding { tree prev_value; } cp_label_binding; -DEF_VEC_O(cp_label_binding); -DEF_VEC_ALLOC_O(cp_label_binding,gc); /* For each binding contour we allocate a binding_level structure which records the names defined in that contour. @@ -195,7 +189,7 @@ struct GTY(()) cp_binding_level { tree namespaces; /* An array of static functions and variables (for namespaces only) */ - VEC(tree,gc) *static_decls; + vec<tree, va_gc> *static_decls; /* A list of USING_DECL nodes. */ tree usings; @@ -206,7 +200,7 @@ struct GTY(()) cp_binding_level { /* For the binding level corresponding to a class, the entities declared in the class or its base classes. */ - VEC(cp_class_binding,gc) *class_shadowed; + vec<cp_class_binding, va_gc> *class_shadowed; /* Similar to class_shadowed, but for IDENTIFIER_TYPE_VALUE, and is used for all binding levels. The TREE_PURPOSE is the name of @@ -217,7 +211,7 @@ struct GTY(()) cp_binding_level { /* Similar to class_shadowed, but for IDENTIFIER_LABEL_VALUE, and used for all binding levels. */ - VEC(cp_label_binding,gc) *shadowed_labels; + vec<cp_label_binding, va_gc> *shadowed_labels; /* For each level (except not the global one), a chain of BLOCK nodes for all the levels @@ -234,7 +228,7 @@ struct GTY(()) cp_binding_level { /* List of VAR_DECLS saved from a previous for statement. These would be dead in ISO-conforming code, but might be referenced in ARM-era code. */ - VEC(tree,gc) *dead_vars_from_for; + vec<tree, va_gc> *dead_vars_from_for; /* STATEMENT_LIST for statements in this binding contour. Only used at present for SK_CLEANUP temporary bindings. */ @@ -327,7 +321,7 @@ extern tree lookup_qualified_name (tree, tree, bool, bool); extern tree lookup_name_nonclass (tree); extern tree lookup_name_innermost_nonclass_level (tree); extern bool is_local_extern (tree); -extern tree lookup_function_nonclass (tree, VEC(tree,gc) *, bool); +extern tree lookup_function_nonclass (tree, vec<tree, va_gc> *, bool); extern void push_local_binding (tree, tree, int); extern bool pushdecl_class_level (tree); extern tree pushdecl_namespace_level (tree, bool); @@ -343,7 +337,7 @@ extern void do_toplevel_using_decl (tree, tree, tree); extern void do_local_using_decl (tree, tree, tree); extern tree do_class_using_decl (tree, tree); extern void do_using_directive (tree); -extern tree lookup_arg_dependent (tree, tree, VEC(tree,gc) *, bool); +extern tree lookup_arg_dependent (tree, tree, vec<tree, va_gc> *, bool); extern bool is_associated_namespace (tree, tree); extern void parse_using_directive (tree, tree); extern tree innermost_non_namespace_value (tree); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 7107134..9650351 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -252,7 +252,7 @@ int cp_unevaluated_operand; highlighted by surrounding it in [[ ]]. */ static void -cp_lexer_dump_tokens (FILE *file, VEC(cp_token,gc) *buffer, +cp_lexer_dump_tokens (FILE *file, vec<cp_token, va_gc> *buffer, cp_token *start_token, unsigned num, cp_token *curr_token) { @@ -260,26 +260,26 @@ cp_lexer_dump_tokens (FILE *file, VEC(cp_token,gc) *buffer, cp_token *token; bool do_print; - fprintf (file, "%u tokens\n", VEC_length (cp_token, buffer)); + fprintf (file, "%u tokens\n", vec_safe_length (buffer)); if (buffer == NULL) return; if (num == 0) - num = VEC_length (cp_token, buffer); + num = buffer->length (); if (start_token == NULL) - start_token = VEC_address (cp_token, buffer); + start_token = buffer->address (); - if (start_token > VEC_address (cp_token, buffer)) + if (start_token > buffer->address ()) { - cp_lexer_print_token (file, &VEC_index (cp_token, buffer, 0)); + cp_lexer_print_token (file, &(*buffer)[0]); fprintf (file, " ... "); } do_print = false; nprinted = 0; - for (i = 0; VEC_iterate (cp_token, buffer, i, token) && nprinted < num; i++) + for (i = 0; buffer->iterate (i, &token) && nprinted < num; i++) { if (token == start_token) do_print = true; @@ -310,10 +310,10 @@ cp_lexer_dump_tokens (FILE *file, VEC(cp_token,gc) *buffer, } } - if (i == num && i < VEC_length (cp_token, buffer)) + if (i == num && i < buffer->length ()) { fprintf (file, " ... "); - cp_lexer_print_token (file, &VEC_last (cp_token, buffer)); + cp_lexer_print_token (file, &buffer->last ()); } fprintf (file, "\n"); @@ -323,7 +323,7 @@ cp_lexer_dump_tokens (FILE *file, VEC(cp_token,gc) *buffer, /* Dump all tokens in BUFFER to stderr. */ void -cp_lexer_debug_tokens (VEC(cp_token,gc) *buffer) +cp_lexer_debug_tokens (vec<cp_token, va_gc> *buffer) { cp_lexer_dump_tokens (stderr, buffer, NULL, 0, NULL); } @@ -393,8 +393,7 @@ cp_debug_print_unparsed_function (FILE *file, cp_unparsed_functions_entry *uf) fprintf (file, "\tFunctions with default args:\n"); for (i = 0; - VEC_iterate (cp_default_arg_entry, uf->funs_with_default_args, i, - default_arg_fn); + vec_safe_iterate (uf->funs_with_default_args, i, &default_arg_fn); i++) { fprintf (file, "\t\tClass type: "); @@ -406,7 +405,7 @@ cp_debug_print_unparsed_function (FILE *file, cp_unparsed_functions_entry *uf) fprintf (file, "\n\tFunctions with definitions that require " "post-processing\n\t\t"); - for (i = 0; VEC_iterate (tree, uf->funs_with_definitions, i, fn); i++) + for (i = 0; vec_safe_iterate (uf->funs_with_definitions, i, &fn); i++) { print_node_brief (file, "", fn, 0); fprintf (file, " "); @@ -415,7 +414,7 @@ cp_debug_print_unparsed_function (FILE *file, cp_unparsed_functions_entry *uf) fprintf (file, "\n\tNon-static data members with initializers that require " "post-processing\n\t\t"); - for (i = 0; VEC_iterate (tree, uf->nsdmis, i, fn); i++) + for (i = 0; vec_safe_iterate (uf->nsdmis, i, &fn); i++) { print_node_brief (file, "", fn, 0); fprintf (file, " "); @@ -428,13 +427,13 @@ cp_debug_print_unparsed_function (FILE *file, cp_unparsed_functions_entry *uf) static void cp_debug_print_unparsed_queues (FILE *file, - VEC(cp_unparsed_functions_entry, gc) *s) + vec<cp_unparsed_functions_entry, va_gc> *s) { unsigned i; cp_unparsed_functions_entry *uf; fprintf (file, "Unparsed functions\n"); - for (i = 0; VEC_iterate (cp_unparsed_functions_entry, s, i, uf); i++) + for (i = 0; vec_safe_iterate (s, i, &uf); i++) { fprintf (file, "#%u:\n", i); cp_debug_print_unparsed_function (file, uf); @@ -454,7 +453,7 @@ cp_debug_parser_tokens (FILE *file, cp_parser *parser, int window_size) file = stderr; next_token = parser->lexer->next_token; - first_token = VEC_address (cp_token, parser->lexer->buffer); + first_token = parser->lexer->buffer->address (); start_token = (next_token > first_token + window_size / 2) ? next_token - window_size / 2 : first_token; @@ -478,7 +477,7 @@ cp_debug_parser (FILE *file, cp_parser *parser) fprintf (file, "Parser state\n\n"); fprintf (file, "Number of tokens: %u\n", - VEC_length (cp_token, parser->lexer->buffer)); + vec_safe_length (parser->lexer->buffer)); cp_debug_print_tree_if_set (file, "Lookup scope", parser->scope); cp_debug_print_tree_if_set (file, "Object scope", parser->object_scope); @@ -563,11 +562,10 @@ cp_lexer_alloc (void) /* Initially we are not debugging. */ lexer->debugging_p = false; - lexer->saved_tokens = VEC_alloc (cp_token_position, heap, - CP_SAVED_TOKEN_STACK); + lexer->saved_tokens.create (CP_SAVED_TOKEN_STACK); /* Create the buffer. */ - lexer->buffer = VEC_alloc (cp_token, gc, CP_LEXER_BUFFER_SIZE); + vec_alloc (lexer->buffer, CP_LEXER_BUFFER_SIZE); return lexer; } @@ -590,20 +588,20 @@ cp_lexer_new_main (void) lexer = cp_lexer_alloc (); /* Put the first token in the buffer. */ - VEC_quick_push (cp_token, lexer->buffer, token); + lexer->buffer->quick_push (token); /* Get the remaining tokens from the preprocessor. */ while (token.type != CPP_EOF) { cp_lexer_get_preprocessor_token (lexer, &token); - VEC_safe_push (cp_token, gc, lexer->buffer, token); + vec_safe_push (lexer->buffer, token); } - lexer->last_token = VEC_address (cp_token, lexer->buffer) - + VEC_length (cp_token, lexer->buffer) + lexer->last_token = lexer->buffer->address () + + lexer->buffer->length () - 1; - lexer->next_token = VEC_length (cp_token, lexer->buffer) - ? VEC_address (cp_token, lexer->buffer) + lexer->next_token = lexer->buffer->length () + ? lexer->buffer->address () : &eof_token; /* Subsequent preprocessor diagnostics should use compiler @@ -629,8 +627,7 @@ cp_lexer_new_from_tokens (cp_token_cache *cache) lexer->next_token = first == last ? &eof_token : first; lexer->last_token = last; - lexer->saved_tokens = VEC_alloc (cp_token_position, heap, - CP_SAVED_TOKEN_STACK); + lexer->saved_tokens.create (CP_SAVED_TOKEN_STACK); /* Initially we are not debugging. */ lexer->debugging_p = false; @@ -644,8 +641,8 @@ cp_lexer_new_from_tokens (cp_token_cache *cache) static void cp_lexer_destroy (cp_lexer *lexer) { - VEC_free (cp_token, gc, lexer->buffer); - VEC_free (cp_token_position, heap, lexer->saved_tokens); + vec_free (lexer->buffer); + lexer->saved_tokens.release (); ggc_free (lexer); } @@ -700,7 +697,7 @@ cp_lexer_previous_token (cp_lexer *lexer) static inline int cp_lexer_saving_tokens (const cp_lexer* lexer) { - return VEC_length (cp_token_position, lexer->saved_tokens) != 0; + return lexer->saved_tokens.length () != 0; } /* Store the next token from the preprocessor in *TOKEN. Return true @@ -1060,8 +1057,7 @@ cp_lexer_save_tokens (cp_lexer* lexer) if (cp_lexer_debugging_p (lexer)) fprintf (cp_lexer_debug_stream, "cp_lexer: saving tokens\n"); - VEC_safe_push (cp_token_position, heap, - lexer->saved_tokens, lexer->next_token); + lexer->saved_tokens.safe_push (lexer->next_token); } /* Commit to the portion of the token stream most recently saved. */ @@ -1073,7 +1069,7 @@ cp_lexer_commit_tokens (cp_lexer* lexer) if (cp_lexer_debugging_p (lexer)) fprintf (cp_lexer_debug_stream, "cp_lexer: committing tokens\n"); - VEC_pop (cp_token_position, lexer->saved_tokens); + lexer->saved_tokens.pop (); } /* Return all tokens saved since the last call to cp_lexer_save_tokens @@ -1086,7 +1082,7 @@ cp_lexer_rollback_tokens (cp_lexer* lexer) if (cp_lexer_debugging_p (lexer)) fprintf (cp_lexer_debug_stream, "cp_lexer: restoring tokens\n"); - lexer->next_token = VEC_pop (cp_token_position, lexer->saved_tokens); + lexer->next_token = lexer->saved_tokens.pop (); } /* Print a representation of the TOKEN on the STREAM. */ @@ -1735,24 +1731,24 @@ cp_parser_context_new (cp_parser_context* next) /* Managing the unparsed function queues. */ #define unparsed_funs_with_default_args \ - VEC_last (cp_unparsed_functions_entry, parser->unparsed_queues).funs_with_default_args + parser->unparsed_queues->last ().funs_with_default_args #define unparsed_funs_with_definitions \ - VEC_last (cp_unparsed_functions_entry, parser->unparsed_queues).funs_with_definitions + parser->unparsed_queues->last ().funs_with_definitions #define unparsed_nsdmis \ - VEC_last (cp_unparsed_functions_entry, parser->unparsed_queues).nsdmis + parser->unparsed_queues->last ().nsdmis static void push_unparsed_function_queues (cp_parser *parser) { cp_unparsed_functions_entry e = {NULL, make_tree_vector (), NULL}; - VEC_safe_push (cp_unparsed_functions_entry, gc, parser->unparsed_queues, e); + vec_safe_push (parser->unparsed_queues, e); } static void pop_unparsed_function_queues (cp_parser *parser) { release_tree_vector (unparsed_funs_with_definitions); - VEC_pop (cp_unparsed_functions_entry, parser->unparsed_queues); + parser->unparsed_queues->pop (); } /* Prototypes. */ @@ -1812,7 +1808,7 @@ static tree cp_parser_postfix_open_square_expression (cp_parser *, tree, bool); static tree cp_parser_postfix_dot_deref_expression (cp_parser *, enum cpp_ttype, tree, bool, cp_id_kind *, location_t); -static VEC(tree,gc) *cp_parser_parenthesized_expression_list +static vec<tree, va_gc> *cp_parser_parenthesized_expression_list (cp_parser *, int, bool, bool, bool *); /* Values for the second parameter of cp_parser_parenthesized_expression_list. */ enum { non_attr = 0, normal_attr = 1, id_attr = 2 }; @@ -1824,7 +1820,7 @@ static enum tree_code cp_parser_unary_operator (cp_token *); static tree cp_parser_new_expression (cp_parser *); -static VEC(tree,gc) *cp_parser_new_placement +static vec<tree, va_gc> *cp_parser_new_placement (cp_parser *); static tree cp_parser_new_type_id (cp_parser *, tree *); @@ -1832,7 +1828,7 @@ static cp_declarator *cp_parser_new_declarator_opt (cp_parser *); static cp_declarator *cp_parser_direct_new_declarator (cp_parser *); -static VEC(tree,gc) *cp_parser_new_initializer +static vec<tree, va_gc> *cp_parser_new_initializer (cp_parser *); static tree cp_parser_delete_expression (cp_parser *); @@ -1964,7 +1960,7 @@ static tree cp_parser_decltype /* Declarators [gram.dcl.decl] */ static tree cp_parser_init_declarator - (cp_parser *, cp_decl_specifier_seq *, VEC (deferred_access_check,gc)*, bool, bool, int, bool *, tree *); + (cp_parser *, cp_decl_specifier_seq *, vec<deferred_access_check, va_gc> *, bool, bool, int, bool *, tree *); static cp_declarator *cp_parser_declarator (cp_parser *, cp_parser_declarator_kind, int *, bool *, bool); static cp_declarator *cp_parser_direct_declarator @@ -2004,7 +2000,7 @@ static tree cp_parser_initializer_clause (cp_parser *, bool *); static tree cp_parser_braced_list (cp_parser*, bool*); -static VEC(constructor_elt,gc) *cp_parser_initializer_list +static vec<constructor_elt, va_gc> *cp_parser_initializer_list (cp_parser *, bool *); static bool cp_parser_ctor_initializer_opt_and_function_body @@ -2220,9 +2216,9 @@ static tree cp_parser_function_definition_after_declarator static void cp_parser_template_declaration_after_export (cp_parser *, bool); static void cp_parser_perform_template_parameter_access_checks - (VEC (deferred_access_check,gc)*); + (vec<deferred_access_check, va_gc> *); static tree cp_parser_single_declaration - (cp_parser *, VEC (deferred_access_check,gc)*, bool, bool, bool *); + (cp_parser *, vec<deferred_access_check, va_gc> *, bool, bool, bool *); static tree cp_parser_functional_cast (cp_parser *, tree); static tree cp_parser_save_member_function_body @@ -3551,7 +3547,7 @@ cp_parser_string_literal (cp_parser *parser, bool translate, bool wide_ok) /* Look up a literal operator with the name and the exact arguments. */ static tree -lookup_literal_operator (tree name, VEC(tree,gc) *args) +lookup_literal_operator (tree name, vec<tree, va_gc> *args) { tree decl, fns; decl = lookup_name (name); @@ -3567,11 +3563,11 @@ lookup_literal_operator (tree name, VEC(tree,gc) *args) argtypes = TYPE_ARG_TYPES (TREE_TYPE (fn)); if (argtypes != NULL_TREE) { - for (ix = 0; ix < VEC_length (tree, args) && argtypes != NULL_TREE; + for (ix = 0; ix < vec_safe_length (args) && argtypes != NULL_TREE; ++ix, argtypes = TREE_CHAIN (argtypes)) { tree targ = TREE_VALUE (argtypes); - tree tparm = TREE_TYPE (VEC_index (tree, args, ix)); + tree tparm = TREE_TYPE ((*args)[ix]); bool ptr = TREE_CODE (targ) == POINTER_TYPE; bool arr = TREE_CODE (tparm) == ARRAY_TYPE; if ((ptr || arr || !same_type_p (targ, tparm)) @@ -3581,7 +3577,7 @@ lookup_literal_operator (tree name, VEC(tree,gc) *args) found = false; } if (found - && ix == VEC_length (tree, args) + && ix == vec_safe_length (args) /* May be this should be sufficient_parms_p instead, depending on how exactly should user-defined literals work in presence of default arguments on the literal @@ -3609,8 +3605,8 @@ cp_parser_userdef_char_literal (cp_parser *parser) /* Build up a call to the user-defined operator */ /* Lookup the name we got back from the id-expression. */ - VEC(tree,gc) *args = make_tree_vector (); - VEC_safe_push (tree, gc, args, value); + vec<tree, va_gc> *args = make_tree_vector (); + vec_safe_push (args, value); decl = lookup_literal_operator (name, args); if (!decl || decl == error_mark_node) { @@ -3668,12 +3664,12 @@ cp_parser_userdef_numeric_literal (cp_parser *parser) tree num_string = USERDEF_LITERAL_NUM_STRING (literal); tree name = cp_literal_operator_id (IDENTIFIER_POINTER (suffix_id)); tree decl, result; - VEC(tree,gc) *args; + vec<tree, va_gc> *args; /* Look for a literal operator taking the exact type of numeric argument as the literal value. */ args = make_tree_vector (); - VEC_safe_push (tree, gc, args, value); + vec_safe_push (args, value); decl = lookup_literal_operator (name, args); if (decl && decl != error_mark_node) { @@ -3690,7 +3686,7 @@ cp_parser_userdef_numeric_literal (cp_parser *parser) operator taking a const char* argument consisting of the number in string format. */ args = make_tree_vector (); - VEC_safe_push (tree, gc, args, num_string); + vec_safe_push (args, num_string); decl = lookup_literal_operator (name, args); if (decl && decl != error_mark_node) { @@ -3742,9 +3738,9 @@ cp_parser_userdef_string_literal (cp_token *token) /* Build up a call to the user-defined operator */ /* Lookup the name we got back from the id-expression. */ - VEC(tree,gc) *args = make_tree_vector (); - VEC_safe_push (tree, gc, args, value); - VEC_safe_push (tree, gc, args, build_int_cst (size_type_node, len)); + vec<tree, va_gc> *args = make_tree_vector (); + vec_safe_push (args, value); + vec_safe_push (args, build_int_cst (size_type_node, len)); decl = lookup_name (name); if (!decl || decl == error_mark_node) { @@ -5496,7 +5492,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, case RID_BUILTIN_SHUFFLE: { - VEC(tree,gc)* vec; + vec<tree, va_gc> *vec; unsigned int i; tree p; location_t loc = token->location; @@ -5508,21 +5504,13 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, if (vec == NULL) return error_mark_node; - FOR_EACH_VEC_ELT (tree, vec, i, p) + FOR_EACH_VEC_ELT (*vec, i, p) mark_exp_read (p); - if (VEC_length (tree, vec) == 2) - return - c_build_vec_perm_expr - (loc, VEC_index (tree, vec, 0), - NULL_TREE, VEC_index (tree, vec, 1)); - - else if (VEC_length (tree, vec) == 3) - return - c_build_vec_perm_expr - (loc, VEC_index (tree, vec, 0), - VEC_index (tree, vec, 1), - VEC_index (tree, vec, 2)); + if (vec->length () == 2) + return c_build_vec_perm_expr (loc, (*vec)[0], NULL_TREE, (*vec)[1]); + else if (vec->length () == 3) + return c_build_vec_perm_expr (loc, (*vec)[0], (*vec)[1], (*vec)[2]); else { error_at (loc, "wrong number of arguments to " @@ -5558,7 +5546,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, if (cp_parser_allow_gnu_extensions_p (parser) && cp_lexer_next_token_is (parser->lexer, CPP_OPEN_PAREN)) { - VEC(constructor_elt,gc) *initializer_list = NULL; + vec<constructor_elt, va_gc> *initializer_list = NULL; bool saved_in_type_id_in_expr_p; cp_parser_parse_tentatively (parser); @@ -5666,7 +5654,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, bool is_builtin_constant_p; bool saved_integral_constant_expression_p = false; bool saved_non_integral_constant_expression_p = false; - VEC(tree,gc) *args; + vec<tree, va_gc> *args; is_member_access = false; @@ -5717,7 +5705,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, { if (TREE_CODE (postfix_expression) == IDENTIFIER_NODE) { - if (!VEC_empty (tree, args)) + if (!args->is_empty ()) { koenig_p = true; if (!any_type_dependent_arguments_p (args)) @@ -5733,7 +5721,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, /* We do not perform argument-dependent lookup if normal lookup finds a non-function, in accordance with the expected resolution of DR 218. */ - else if (!VEC_empty (tree, args) + else if (!args->is_empty () && is_overloaded_fn (postfix_expression)) { tree fn = get_first_fn (postfix_expression); @@ -6154,14 +6142,14 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser, NON_CONSTANT_P is non-NULL, *NON_CONSTANT_P indicates whether or not all of the expressions in the list were constant. */ -static VEC(tree,gc) * +static vec<tree, va_gc> * cp_parser_parenthesized_expression_list (cp_parser* parser, int is_attribute_list, bool cast_p, bool allow_expansion_p, bool *non_constant_p) { - VEC(tree,gc) *expression_list; + vec<tree, va_gc> *expression_list; bool fold_expr_p = is_attribute_list != non_attr; tree identifier = NULL_TREE; bool saved_greater_than_is_operator_p; @@ -6242,7 +6230,7 @@ cp_parser_parenthesized_expression_list (cp_parser* parser, expressions to the list, so that we can still tell if the correct form for a parenthesized expression-list is found. That gives better errors. */ - VEC_safe_push (tree, gc, expression_list, expr); + vec_safe_push (expression_list, expr); if (expr == error_mark_node) goto skip_comma; @@ -6286,7 +6274,7 @@ cp_parser_parenthesized_expression_list (cp_parser* parser, = saved_greater_than_is_operator_p; if (identifier) - VEC_safe_insert (tree, gc, expression_list, 0, identifier); + vec_safe_insert (expression_list, 0, identifier); return expression_list; } @@ -6725,9 +6713,9 @@ static tree cp_parser_new_expression (cp_parser* parser) { bool global_scope_p; - VEC(tree,gc) *placement; + vec<tree, va_gc> *placement; tree type; - VEC(tree,gc) *initializer; + vec<tree, va_gc> *initializer; tree nelts = NULL_TREE; tree ret; @@ -6819,10 +6807,10 @@ cp_parser_new_expression (cp_parser* parser) Returns the same representation as for an expression-list. */ -static VEC(tree,gc) * +static vec<tree, va_gc> * cp_parser_new_placement (cp_parser* parser) { - VEC(tree,gc) *expression_list; + vec<tree, va_gc> *expression_list; /* Parse the expression-list. */ expression_list = (cp_parser_parenthesized_expression_list @@ -7014,10 +7002,10 @@ cp_parser_direct_new_declarator (cp_parser* parser) Returns a representation of the expression-list. */ -static VEC(tree,gc) * +static vec<tree, va_gc> * cp_parser_new_initializer (cp_parser* parser) { - VEC(tree,gc) *expression_list; + vec<tree, va_gc> *expression_list; if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) { @@ -8084,9 +8072,7 @@ typedef struct GTY(()) tree_int tree t; int i; } tree_int; -DEF_VEC_O(tree_int); -DEF_VEC_ALLOC_O(tree_int,gc); -static GTY(()) VEC(tree_int,gc) *lambda_scope_stack; +static GTY(()) vec<tree_int, va_gc> *lambda_scope_stack; static void start_lambda_scope (tree decl) @@ -8099,7 +8085,7 @@ start_lambda_scope (tree decl) decl = current_function_decl; ti.t = lambda_scope; ti.i = lambda_count; - VEC_safe_push (tree_int, gc, lambda_scope_stack, ti); + vec_safe_push (lambda_scope_stack, ti); if (lambda_scope != decl) { /* Don't reset the count if we're still in the same function. */ @@ -8118,13 +8104,13 @@ record_lambda_scope (tree lambda) static void finish_lambda_scope (void) { - tree_int *p = &VEC_last (tree_int, lambda_scope_stack); + tree_int *p = &lambda_scope_stack->last (); if (lambda_scope != p->t) { lambda_scope = p->t; lambda_count = p->i; } - VEC_pop (tree_int, lambda_scope_stack); + lambda_scope_stack->pop (); } /* Parse a lambda expression. @@ -9716,10 +9702,10 @@ cp_parser_perform_range_for_lookup (tree range, tree *begin, tree *end) else { /* Use global functions with ADL. */ - VEC(tree,gc) *vec; + vec<tree, va_gc> *vec; vec = make_tree_vector (); - VEC_safe_push (tree, gc, vec, range); + vec_safe_push (vec, range); member_begin = perform_koenig_lookup (id_begin, vec, /*include_std=*/true, @@ -9763,7 +9749,7 @@ static tree cp_parser_range_for_member_function (tree range, tree identifier) { tree member, res; - VEC(tree,gc) *vec; + vec<tree, va_gc> *vec; member = finish_class_member_access_expr (range, identifier, false, tf_warning_or_error); @@ -11671,7 +11657,7 @@ cp_parser_mem_initializer (cp_parser* parser) } else { - VEC(tree,gc)* vec; + vec<tree, va_gc> *vec; vec = cp_parser_parenthesized_expression_list (parser, non_attr, /*cast_p=*/false, /*allow_expansion_p=*/true, @@ -12566,7 +12552,7 @@ cp_parser_template_id (cp_parser *parser, tree template_id; cp_token_position start_of_id = 0; deferred_access_check *chk; - VEC (deferred_access_check,gc) *access_check; + vec<deferred_access_check, va_gc> *access_check; cp_token *next_token = NULL, *next_token_2 = NULL; bool is_identifier; @@ -12583,7 +12569,7 @@ cp_parser_template_id (cp_parser *parser, access_check = check_value->checks; if (access_check) { - FOR_EACH_VEC_ELT (deferred_access_check, access_check, i, chk) + FOR_EACH_VEC_ELT (*access_check, i, chk) perform_or_defer_access_check (chk->binfo, chk->decl, chk->diag_decl, @@ -15664,7 +15650,7 @@ cp_parser_asm_definition (cp_parser* parser) static tree cp_parser_init_declarator (cp_parser* parser, cp_decl_specifier_seq *decl_specifiers, - VEC (deferred_access_check,gc)* checks, + vec<deferred_access_check, va_gc> *checks, bool function_definition_allowed_p, bool member_p, int declares_class_or_enum, @@ -17744,7 +17730,7 @@ cp_parser_initializer (cp_parser* parser, bool* is_direct_init, } else if (token->type == CPP_OPEN_PAREN) { - VEC(tree,gc) *vec; + vec<tree, va_gc> *vec; vec = cp_parser_parenthesized_expression_list (parser, non_attr, /*cast_p=*/false, /*allow_expansion_p=*/true, @@ -17861,15 +17847,15 @@ cp_parser_braced_list (cp_parser* parser, bool* non_constant_p) identifier : [ constant-expression ] = - Returns a VEC of constructor_elt. The VALUE of each elt is an expression + Returns a vec of constructor_elt. The VALUE of each elt is an expression for the initializer. If the INDEX of the elt is non-NULL, it is the IDENTIFIER_NODE naming the field to initialize. NON_CONSTANT_P is as for cp_parser_initializer. */ -static VEC(constructor_elt,gc) * +static vec<constructor_elt, va_gc> * cp_parser_initializer_list (cp_parser* parser, bool* non_constant_p) { - VEC(constructor_elt,gc) *v = NULL; + vec<constructor_elt, va_gc> *v = NULL; /* Assume all of the expressions are constant. */ *non_constant_p = false; @@ -18370,8 +18356,7 @@ cp_parser_class_specifier_1 (cp_parser* parser) }; */ - FOR_EACH_VEC_ELT (cp_default_arg_entry, unparsed_funs_with_default_args, - ix, e) + FOR_EACH_VEC_SAFE_ELT (unparsed_funs_with_default_args, ix, e) { decl = e->decl; /* If there are default arguments that have not yet been processed, @@ -18390,11 +18375,11 @@ cp_parser_class_specifier_1 (cp_parser* parser) /* Remove any template parameters from the symbol table. */ maybe_end_member_template_processing (); } - VEC_truncate (cp_default_arg_entry, unparsed_funs_with_default_args, 0); + vec_safe_truncate (unparsed_funs_with_default_args, 0); /* Now parse any NSDMIs. */ save_ccp = current_class_ptr; save_ccr = current_class_ref; - FOR_EACH_VEC_ELT (tree, unparsed_nsdmis, ix, decl) + FOR_EACH_VEC_SAFE_ELT (unparsed_nsdmis, ix, decl) { if (class_type != DECL_CONTEXT (decl)) { @@ -18406,15 +18391,15 @@ cp_parser_class_specifier_1 (cp_parser* parser) inject_this_parameter (class_type, TYPE_UNQUALIFIED); cp_parser_late_parsing_nsdmi (parser, decl); } - VEC_truncate (tree, unparsed_nsdmis, 0); + vec_safe_truncate (unparsed_nsdmis, 0); current_class_ptr = save_ccp; current_class_ref = save_ccr; if (pushed_scope) pop_scope (pushed_scope); /* Now parse the body of the functions. */ - FOR_EACH_VEC_ELT (tree, unparsed_funs_with_definitions, ix, decl) + FOR_EACH_VEC_SAFE_ELT (unparsed_funs_with_definitions, ix, decl) cp_parser_late_parsing_for_member (parser, decl); - VEC_truncate (tree, unparsed_funs_with_definitions, 0); + vec_safe_truncate (unparsed_funs_with_definitions, 0); } /* Put back any saved access checks. */ @@ -19453,7 +19438,7 @@ cp_parser_member_declaration (cp_parser* parser) && !DECL_C_BIT_FIELD (decl) && DECL_INITIAL (decl)) /* Add DECL to the queue of NSDMI to be parsed later. */ - VEC_safe_push (tree, gc, unparsed_nsdmis, decl); + vec_safe_push (unparsed_nsdmis, decl); } if (assume_semicolon) @@ -20503,7 +20488,7 @@ cp_parser_gnu_attribute_list (cp_parser* parser) /* If it's an `(', then parse the attribute arguments. */ if (token->type == CPP_OPEN_PAREN) { - VEC(tree,gc) *vec; + vec<tree, va_gc> *vec; int attr_flag = (attribute_takes_identifier_p (identifier) ? id_attr : normal_attr); vec = cp_parser_parenthesized_expression_list @@ -20640,7 +20625,7 @@ cp_parser_std_attribute (cp_parser *parser) return attribute; { - VEC(tree, gc) *vec; + vec<tree, va_gc> *vec; int attr_flag = normal_attr; if (attr_ns == get_identifier ("gnu") @@ -21672,7 +21657,7 @@ static void cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p) { tree decl = NULL_TREE; - VEC (deferred_access_check,gc) *checks; + vec<deferred_access_check, va_gc> *checks; tree parameter_list; bool friend_p = false; bool need_lang_pop; @@ -21824,7 +21809,7 @@ cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p) if (member_p && decl && (TREE_CODE (decl) == FUNCTION_DECL || DECL_FUNCTION_TEMPLATE_P (decl))) - VEC_safe_push (tree, gc, unparsed_funs_with_definitions, decl); + vec_safe_push (unparsed_funs_with_definitions, decl); } /* Perform the deferred access checks from a template-parameter-list. @@ -21832,7 +21817,7 @@ cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p) get_deferred_access_checks. */ static void -cp_parser_perform_template_parameter_access_checks (VEC (deferred_access_check,gc)* checks) +cp_parser_perform_template_parameter_access_checks (vec<deferred_access_check, va_gc> *checks) { ++processing_template_parmlist; perform_access_checks (checks, tf_warning_or_error); @@ -21848,7 +21833,7 @@ cp_parser_perform_template_parameter_access_checks (VEC (deferred_access_check,g static tree cp_parser_single_declaration (cp_parser* parser, - VEC (deferred_access_check,gc)* checks, + vec<deferred_access_check, va_gc> *checks, bool member_p, bool explicit_specialization_p, bool* friend_p) @@ -21999,7 +21984,7 @@ cp_parser_simple_cast_expression (cp_parser *parser) static tree cp_parser_functional_cast (cp_parser* parser, tree type) { - VEC(tree,gc) *vec; + vec<tree, va_gc> *vec; tree expression_list; tree cast; bool nonconst_p; @@ -22108,7 +22093,7 @@ cp_parser_save_member_function_body (cp_parser* parser, DECL_INITIALIZED_IN_CLASS_P (fn) = 1; /* Add FN to the queue of functions to be parsed later. */ - VEC_safe_push (tree, gc, unparsed_funs_with_definitions, fn); + vec_safe_push (unparsed_funs_with_definitions, fn); return fn; } @@ -22319,8 +22304,7 @@ cp_parser_save_default_args (cp_parser* parser, tree decl) if (TREE_PURPOSE (probe)) { cp_default_arg_entry entry = {current_class_type, decl}; - VEC_safe_push (cp_default_arg_entry, gc, - unparsed_funs_with_default_args, entry); + vec_safe_push (unparsed_funs_with_default_args, entry); break; } } @@ -22440,7 +22424,7 @@ cp_parser_late_parsing_default_args (cp_parser *parser, tree fn) { tree default_arg = TREE_PURPOSE (parm); tree parsed_arg; - VEC(tree,gc) *insts; + vec<tree, va_gc> *insts; tree copy; unsigned ix; @@ -22465,7 +22449,7 @@ cp_parser_late_parsing_default_args (cp_parser *parser, tree fn) /* Update any instantiations we've already created. */ for (insts = DEFARG_INSTANTIATIONS (default_arg), ix = 0; - VEC_iterate (tree, insts, ix, copy); ix++) + vec_safe_iterate (insts, ix, ©); ix++) TREE_PURPOSE (copy) = parsed_arg; } @@ -23298,7 +23282,7 @@ cp_parser_pre_parsed_nested_name_specifier (cp_parser *parser) int i; struct tree_check *check_value; deferred_access_check *chk; - VEC (deferred_access_check,gc) *checks; + vec<deferred_access_check, va_gc> *checks; /* Get the stored value. */ check_value = cp_lexer_consume_token (parser->lexer)->u.tree_check_value; @@ -23306,7 +23290,7 @@ cp_parser_pre_parsed_nested_name_specifier (cp_parser *parser) checks = check_value->checks; if (checks) { - FOR_EACH_VEC_ELT (deferred_access_check, checks, i, chk) + FOR_EACH_VEC_SAFE_ELT (checks, i, chk) perform_or_defer_access_check (chk->binfo, chk->decl, chk->diag_decl, tf_warning_or_error); @@ -26875,7 +26859,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses) location_t loc_first; bool collapse_err = false; int i, collapse = 1, nbraces = 0; - VEC(tree,gc) *for_block = make_tree_vector (); + vec<tree, va_gc> *for_block = make_tree_vector (); for (cl = clauses; cl; cl = OMP_CLAUSE_CHAIN (cl)) if (OMP_CLAUSE_CODE (cl) == OMP_CLAUSE_COLLAPSE) @@ -26994,7 +26978,7 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses) LOOKUP_ONLYCONVERTING); if (CLASS_TYPE_P (TREE_TYPE (decl))) { - VEC_safe_push (tree, gc, for_block, this_pre_body); + vec_safe_push (for_block, this_pre_body); init = NULL_TREE; } else @@ -27252,8 +27236,8 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses) } } - while (!VEC_empty (tree, for_block)) - add_stmt (pop_stmt_list (VEC_pop (tree, for_block))); + while (!for_block->is_empty ()) + add_stmt (pop_stmt_list (for_block->pop ())); release_tree_vector (for_block); return ret; diff --git a/gcc/cp/parser.h b/gcc/cp/parser.h index 5b95f08..cf281c4 100644 --- a/gcc/cp/parser.h +++ b/gcc/cp/parser.h @@ -30,7 +30,7 @@ struct GTY(()) tree_check { /* The value associated with the token. */ tree value; /* The checks that have been associated with value. */ - VEC (deferred_access_check, gc)* checks; + vec<deferred_access_check, va_gc> *checks; /* The token's qualifying scope (used when it is a CPP_NESTED_NAME_SPECIFIER). */ tree qualifying_scope; @@ -69,14 +69,9 @@ typedef struct GTY (()) cp_token { } GTY((desc ("(%1.type == CPP_TEMPLATE_ID) || (%1.type == CPP_NESTED_NAME_SPECIFIER)"))) u; } cp_token; -DEF_VEC_O (cp_token); -DEF_VEC_ALLOC_O (cp_token,gc); -DEF_VEC_ALLOC_O (cp_token,heap); /* We use a stack of token pointer for saving token sets. */ typedef struct cp_token *cp_token_position; -DEF_VEC_P (cp_token_position); -DEF_VEC_ALLOC_P (cp_token_position,heap); /* The cp_lexer structure represents the C++ lexer. It is responsible for managing the token stream from the preprocessor and supplying @@ -86,7 +81,7 @@ DEF_VEC_ALLOC_P (cp_token_position,heap); typedef struct GTY (()) cp_lexer { /* The memory allocated for the buffer. NULL if this lexer does not own the token buffer. */ - VEC(cp_token,gc) *buffer; + vec<cp_token, va_gc> *buffer; /* A pointer just past the last available token. The tokens in this lexer are [buffer, last_token). */ @@ -100,7 +95,7 @@ typedef struct GTY (()) cp_lexer { called. The top entry is the most recent position at which we began saving tokens. If the stack is non-empty, we are saving tokens. */ - VEC(cp_token_position,heap) *GTY ((skip)) saved_tokens; + vec<cp_token_position> GTY ((skip)) saved_tokens; /* The next lexer in a linked list of lexers. */ struct cp_lexer *next; @@ -113,8 +108,6 @@ typedef struct GTY (()) cp_lexer { bool in_pragma; } cp_lexer; -DEF_VEC_O (cp_lexer); -DEF_VEC_ALLOC_O (cp_lexer,heap); /* cp_token_cache is a range of tokens. There is no need to represent allocate heap memory for it, since tokens are never removed from the @@ -131,8 +124,6 @@ typedef struct GTY(()) cp_token_cache { } cp_token_cache; typedef cp_token_cache *cp_token_cache_ptr; -DEF_VEC_P (cp_token_cache_ptr); -DEF_VEC_ALLOC_P (cp_token_cache_ptr,gc); struct cp_token_ident_d { @@ -156,27 +147,23 @@ typedef struct GTY(()) cp_default_arg_entry_d { tree decl; } cp_default_arg_entry; -DEF_VEC_O(cp_default_arg_entry); -DEF_VEC_ALLOC_O(cp_default_arg_entry,gc); /* An entry in a stack for member functions of local classes. */ typedef struct GTY(()) cp_unparsed_functions_entry_d { /* Functions with default arguments that require post-processing. Functions appear in this list in declaration order. */ - VEC(cp_default_arg_entry,gc) *funs_with_default_args; + vec<cp_default_arg_entry, va_gc> *funs_with_default_args; /* Functions with defintions that require post-processing. Functions appear in this list in declaration order. */ - VEC(tree,gc) *funs_with_definitions; + vec<tree, va_gc> *funs_with_definitions; /* Non-static data members with initializers that require post-processing. FIELD_DECLs appear in this list in declaration order. */ - VEC(tree,gc) *nsdmis; + vec<tree, va_gc> *nsdmis; } cp_unparsed_functions_entry; -DEF_VEC_O(cp_unparsed_functions_entry); -DEF_VEC_ALLOC_O(cp_unparsed_functions_entry,gc); /* The status of a tentative parse. */ @@ -344,7 +331,7 @@ typedef struct GTY(()) cp_parser { /* A stack used for member functions of local classes. The lists contained in an individual entry can only be processed once the outermost class being defined is complete. */ - VEC(cp_unparsed_functions_entry,gc) *unparsed_queues; + vec<cp_unparsed_functions_entry, va_gc> *unparsed_queues; /* The number of classes whose definitions are currently in progress. */ @@ -356,7 +343,7 @@ typedef struct GTY(()) cp_parser { } cp_parser; /* In parser.c */ -extern void cp_lexer_debug_tokens (VEC(cp_token,gc) *); +extern void cp_lexer_debug_tokens (vec<cp_token, va_gc> *); extern void cp_debug_parser (FILE *, cp_parser *); #endif /* GCC_CP_PARSER_H */ diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 101b22d..ecb013e 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -43,7 +43,6 @@ along with GCC; see the file COPYING3. If not see #include "toplev.h" #include "timevar.h" #include "tree-iterator.h" -#include "vecprim.h" /* The type of functions taking a tree, and some additional data, and returning an int. */ @@ -64,7 +63,7 @@ int processing_template_parmlist; static int template_header_count; static GTY(()) tree saved_trees; -static VEC(int,heap) *inline_parm_levels; +static vec<int> inline_parm_levels; static GTY(()) struct tinst_level *current_tinst_level; @@ -100,7 +99,7 @@ static GTY ((param_is (spec_entry))) the TEMPLATE_TYPE_IDX of the template parameter. Each element is a TREE_LIST, whose TREE_VALUEs contain the canonical template parameters of various types and levels. */ -static GTY(()) VEC(tree,gc) *canonical_template_parms; +static GTY(()) vec<tree, va_gc> *canonical_template_parms; #define UNIFY_ALLOW_NONE 0 #define UNIFY_ALLOW_MORE_CV_QUAL 1 @@ -473,7 +472,7 @@ maybe_begin_member_template_processing (tree decl) /* Remember how many levels of template parameters we pushed so that we can pop them later. */ - VEC_safe_push (int, heap, inline_parm_levels, levels); + inline_parm_levels.safe_push (levels); } /* Undo the effects of maybe_begin_member_template_processing. */ @@ -484,10 +483,10 @@ maybe_end_member_template_processing (void) int i; int last; - if (VEC_length (int, inline_parm_levels) == 0) + if (inline_parm_levels.length () == 0) return; - last = VEC_pop (int, inline_parm_levels); + last = inline_parm_levels.pop (); for (i = 0; i < last; ++i) { --processing_template_decl; @@ -1018,7 +1017,7 @@ retrieve_specialization (tree tmpl, tree args, hashval_t hash) { tree class_template; tree class_specialization; - VEC(tree,gc) *methods; + vec<tree, va_gc> *methods; tree fns; int idx; @@ -1038,7 +1037,7 @@ retrieve_specialization (tree tmpl, tree args, hashval_t hash) /* Iterate through the methods with the indicated name, looking for the one that has an instance of TMPL. */ methods = CLASSTYPE_METHOD_VEC (class_specialization); - for (fns = VEC_index (tree, methods, idx); fns; fns = OVL_NEXT (fns)) + for (fns = (*methods)[idx]; fns; fns = OVL_NEXT (fns)) { tree fn = OVL_CURRENT (fns); if (DECL_TEMPLATE_INFO (fn) && DECL_TI_TEMPLATE (fn) == tmpl @@ -2548,11 +2547,11 @@ check_explicit_specialization (tree declarator, { idx = lookup_fnfields_1 (ctype, name); if (idx >= 0) - fns = VEC_index (tree, CLASSTYPE_METHOD_VEC (ctype), idx); + fns = (*CLASSTYPE_METHOD_VEC (ctype))[idx]; } else { - VEC(tree,gc) *methods; + vec<tree, va_gc> *methods; tree ovl; /* For a type-conversion operator, we cannot do a @@ -2565,7 +2564,7 @@ check_explicit_specialization (tree declarator, methods = CLASSTYPE_METHOD_VEC (ctype); if (methods) for (idx = CLASSTYPE_FIRST_CONVERSION_SLOT; - VEC_iterate (tree, methods, idx, ovl); + methods->iterate (idx, &ovl); ++idx) { if (!DECL_CONV_FN_P (OVL_CURRENT (ovl))) @@ -3513,12 +3512,12 @@ canonical_type_parameter (tree type) tree list; int idx = TEMPLATE_TYPE_IDX (type); if (!canonical_template_parms) - canonical_template_parms = VEC_alloc (tree, gc, idx+1); + vec_alloc (canonical_template_parms, idx+1); - while (VEC_length (tree, canonical_template_parms) <= (unsigned)idx) - VEC_safe_push (tree, gc, canonical_template_parms, NULL_TREE); + while (canonical_template_parms->length () <= (unsigned)idx) + vec_safe_push (canonical_template_parms, NULL_TREE); - list = VEC_index (tree, canonical_template_parms, idx); + list = (*canonical_template_parms)[idx]; while (list && !comptypes (type, TREE_VALUE (list), COMPARE_STRUCTURAL)) list = TREE_CHAIN (list); @@ -3526,9 +3525,9 @@ canonical_type_parameter (tree type) return TREE_VALUE (list); else { - VEC_replace(tree, canonical_template_parms, idx, - tree_cons (NULL_TREE, type, - VEC_index (tree, canonical_template_parms, idx))); + (*canonical_template_parms)[idx] + = tree_cons (NULL_TREE, type, + (*canonical_template_parms)[idx]); return type; } } @@ -8457,7 +8456,7 @@ static void perform_typedefs_access_check (tree tmpl, tree targs) { location_t saved_location; - int i; + unsigned i; qualified_typedef_usage_t *iter; if (!tmpl @@ -8466,9 +8465,7 @@ perform_typedefs_access_check (tree tmpl, tree targs) return; saved_location = input_location; - FOR_EACH_VEC_ELT (qualified_typedef_usage_t, - get_types_needing_access_check (tmpl), - i, iter) + FOR_EACH_VEC_SAFE_ELT (get_types_needing_access_check (tmpl), i, iter) { tree type_decl = iter->typedef_decl; tree type_scope = iter->context; @@ -10729,8 +10726,7 @@ tsubst_arg_types (tree arg_types, argument in a call of this function. */ remaining_arg_types = tree_cons (default_arg, type, remaining_arg_types); - VEC_safe_push (tree, gc, DEFARG_INSTANTIATIONS (default_arg), - remaining_arg_types); + vec_safe_push (DEFARG_INSTANTIATIONS(default_arg), remaining_arg_types); } else remaining_arg_types = @@ -13626,8 +13622,8 @@ tsubst_copy_and_build (tree t, { tree placement = RECUR (TREE_OPERAND (t, 0)); tree init = RECUR (TREE_OPERAND (t, 3)); - VEC(tree,gc) *placement_vec; - VEC(tree,gc) *init_vec; + vec<tree, va_gc> *placement_vec; + vec<tree, va_gc> *init_vec; tree ret; if (placement == NULL_TREE) @@ -13636,7 +13632,7 @@ tsubst_copy_and_build (tree t, { placement_vec = make_tree_vector (); for (; placement != NULL_TREE; placement = TREE_CHAIN (placement)) - VEC_safe_push (tree, gc, placement_vec, TREE_VALUE (placement)); + vec_safe_push (placement_vec, TREE_VALUE (placement)); } /* If there was an initializer in the original tree, but it @@ -13655,7 +13651,7 @@ tsubst_copy_and_build (tree t, else { for (; init != NULL_TREE; init = TREE_CHAIN (init)) - VEC_safe_push (tree, gc, init_vec, TREE_VALUE (init)); + vec_safe_push (init_vec, TREE_VALUE (init)); } } @@ -13691,7 +13687,7 @@ tsubst_copy_and_build (tree t, case CALL_EXPR: { tree function; - VEC(tree,gc) *call_args; + vec<tree, va_gc> *call_args; unsigned int nargs, i; bool qualified_p; bool koenig_p; @@ -13751,8 +13747,7 @@ tsubst_copy_and_build (tree t, tree arg = CALL_EXPR_ARG (t, i); if (!PACK_EXPANSION_P (arg)) - VEC_safe_push (tree, gc, call_args, - RECUR (CALL_EXPR_ARG (t, i))); + vec_safe_push (call_args, RECUR (CALL_EXPR_ARG (t, i))); else { /* Expand the pack expansion and push each entry onto @@ -13768,13 +13763,13 @@ tsubst_copy_and_build (tree t, tree value = TREE_VEC_ELT (arg, j); if (value != NULL_TREE) value = convert_from_reference (value); - VEC_safe_push (tree, gc, call_args, value); + vec_safe_push (call_args, value); } } else { /* A partial substitution. Add one entry. */ - VEC_safe_push (tree, gc, call_args, arg); + vec_safe_push (call_args, arg); } } } @@ -14123,7 +14118,7 @@ tsubst_copy_and_build (tree t, case CONSTRUCTOR: { - VEC(constructor_elt,gc) *n; + vec<constructor_elt, va_gc> *n; constructor_elt *ce; unsigned HOST_WIDE_INT idx; tree type = tsubst (TREE_TYPE (t), args, complain, in_decl); @@ -14144,9 +14139,9 @@ tsubst_copy_and_build (tree t, looked up by digest_init. */ process_index_p = !(type && MAYBE_CLASS_TYPE_P (type)); - n = VEC_copy (constructor_elt, gc, CONSTRUCTOR_ELTS (t)); - newlen = VEC_length (constructor_elt, n); - FOR_EACH_VEC_ELT (constructor_elt, n, idx, ce) + n = vec_safe_copy (CONSTRUCTOR_ELTS (t)); + newlen = vec_safe_length (n); + FOR_EACH_VEC_SAFE_ELT (n, idx, ce) { if (ce->index && process_index_p) ce->index = RECUR (ce->index); @@ -14178,10 +14173,10 @@ tsubst_copy_and_build (tree t, if (need_copy_p) { - VEC(constructor_elt,gc) *old_n = n; + vec<constructor_elt, va_gc> *old_n = n; - n = VEC_alloc (constructor_elt, gc, newlen); - FOR_EACH_VEC_ELT (constructor_elt, old_n, idx, ce) + vec_alloc (n, newlen); + FOR_EACH_VEC_ELT (*old_n, idx, ce) { if (TREE_CODE (ce->value) == TREE_VEC) { @@ -19791,12 +19786,12 @@ type_dependent_expression_p_push (tree expr) /* Returns TRUE if ARGS contains a type-dependent expression. */ bool -any_type_dependent_arguments_p (const VEC(tree,gc) *args) +any_type_dependent_arguments_p (const vec<tree, va_gc> *args) { unsigned int i; tree arg; - FOR_EACH_VEC_ELT (tree, args, i, arg) + FOR_EACH_VEC_SAFE_ELT (args, i, arg) { if (type_dependent_expression_p (arg)) return true; @@ -20249,16 +20244,16 @@ build_non_dependent_expr (tree expr) This modifies ARGS in place. */ void -make_args_non_dependent (VEC(tree,gc) *args) +make_args_non_dependent (vec<tree, va_gc> *args) { unsigned int ix; tree arg; - FOR_EACH_VEC_ELT (tree, args, ix, arg) + FOR_EACH_VEC_SAFE_ELT (args, ix, arg) { tree newarg = build_non_dependent_expr (arg); if (newarg != arg) - VEC_replace (tree, args, ix, newarg); + (*args)[ix] = newarg; } } @@ -20459,11 +20454,11 @@ type_uses_auto (tree type) Those typedefs were added to T by the function append_type_to_template_for_access_check. */ -VEC(qualified_typedef_usage_t,gc)* +vec<qualified_typedef_usage_t, va_gc> * get_types_needing_access_check (tree t) { tree ti; - VEC(qualified_typedef_usage_t,gc) *result = NULL; + vec<qualified_typedef_usage_t, va_gc> *result = NULL; if (!t || t == error_mark_node) return NULL; @@ -20521,9 +20516,7 @@ append_type_to_template_for_access_check_1 (tree t, typedef_usage.context = scope; typedef_usage.locus = location; - VEC_safe_push (qualified_typedef_usage_t, gc, - TI_TYPEDEFS_NEEDING_ACCESS_CHECKING (ti), - typedef_usage); + vec_safe_push (TI_TYPEDEFS_NEEDING_ACCESS_CHECKING (ti), typedef_usage); } /* Append TYPE_DECL to the template TEMPL. @@ -20562,14 +20555,12 @@ append_type_to_template_for_access_check (tree templ, location_t location) { qualified_typedef_usage_t *iter; - int i; + unsigned i; gcc_assert (type_decl && (TREE_CODE (type_decl) == TYPE_DECL)); /* Make sure we don't append the type to the template twice. */ - FOR_EACH_VEC_ELT (qualified_typedef_usage_t, - get_types_needing_access_check (templ), - i, iter) + FOR_EACH_VEC_SAFE_ELT (get_types_needing_access_check (templ), i, iter) if (iter->typedef_decl == type_decl && scope == iter->context) return; diff --git a/gcc/cp/repo.c b/gcc/cp/repo.c index ca971b6..06e2693 100644 --- a/gcc/cp/repo.c +++ b/gcc/cp/repo.c @@ -43,7 +43,7 @@ static FILE *open_repo_file (const char *); static char *afgets (FILE *); static FILE *reopen_repo_file_for_write (void); -static GTY(()) VEC(tree,gc) *pending_repo; +static GTY(()) vec<tree, va_gc> *pending_repo; static char *repo_name; static const char *old_args, *old_dir, *old_main; @@ -268,7 +268,7 @@ finish_repo (void) fprintf (repo_file, "\n"); } - FOR_EACH_VEC_ELT_REVERSE (tree, pending_repo, ix, val) + FOR_EACH_VEC_SAFE_ELT_REVERSE (pending_repo, ix, val) { tree name = DECL_ASSEMBLER_NAME (val); char type = IDENTIFIER_REPO_CHOSEN (name) ? 'C' : 'O'; @@ -353,7 +353,7 @@ repo_emit_p (tree decl) if (!DECL_REPO_AVAILABLE_P (decl)) { DECL_REPO_AVAILABLE_P (decl) = 1; - VEC_safe_push (tree, gc, pending_repo, decl); + vec_safe_push (pending_repo, decl); } return IDENTIFIER_REPO_CHOSEN (DECL_ASSEMBLER_NAME (decl)) ? 1 : ret; diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 95518cf..b13ec17 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -72,8 +72,6 @@ typedef struct GTY (()) tinfo_s { the type_info derived type. */ } tinfo_s; -DEF_VEC_O(tinfo_s); -DEF_VEC_ALLOC_O(tinfo_s,gc); typedef enum tinfo_kind { @@ -92,12 +90,12 @@ typedef enum tinfo_kind } tinfo_kind; /* A vector of all tinfo decls that haven't yet been emitted. */ -VEC(tree,gc) *unemitted_tinfo_decls; +vec<tree, va_gc> *unemitted_tinfo_decls; /* A vector of all type_info derived types we need. The first few are fixed and created early. The remainder are for multiple inheritance and are generated as needed. */ -static GTY (()) VEC(tinfo_s,gc) *tinfo_descs; +static GTY (()) vec<tinfo_s, va_gc> *tinfo_descs; static tree ifnonnull (tree, tree, tsubst_flags_t); static tree tinfo_name (tree, bool); @@ -155,7 +153,7 @@ init_rtti_processing (void) = cp_build_qualified_type (type_info_type, TYPE_QUAL_CONST); type_info_ptr_type = build_pointer_type (const_type_info_type_node); - unemitted_tinfo_decls = VEC_alloc (tree, gc, 124); + vec_alloc (unemitted_tinfo_decls, 124); create_tinfo_types (); } @@ -294,8 +292,7 @@ typeid_ok_p (void) return false; } - pseudo_type_info - = VEC_index (tinfo_s, tinfo_descs, TK_TYPE_INFO_TYPE).type; + pseudo_type_info = (*tinfo_descs)[TK_TYPE_INFO_TYPE].type; type_info_type = TYPE_MAIN_VARIANT (const_type_info_type_node); /* Make sure abi::__type_info_pseudo has the same alias set @@ -422,7 +419,7 @@ get_tinfo_decl (tree type) if (!d) { int ix = get_pseudo_ti_index (type); - tinfo_s *ti = &VEC_index (tinfo_s, tinfo_descs, ix); + tinfo_s *ti = &(*tinfo_descs)[ix]; d = build_lang_decl (VAR_DECL, name, ti->type); SET_DECL_ASSEMBLER_NAME (d, name); @@ -444,7 +441,7 @@ get_tinfo_decl (tree type) CLASSTYPE_TYPEINFO_VAR (TYPE_MAIN_VARIANT (type)) = d; /* Add decl to the global array of tinfo decls. */ - VEC_safe_push (tree, gc, unemitted_tinfo_decls, d); + vec_safe_push (unemitted_tinfo_decls, d); } return d; @@ -873,7 +870,7 @@ tinfo_base_init (tinfo_s *ti, tree target) tree init; tree name_decl; tree vtable_ptr; - VEC(constructor_elt,gc) *v; + vec<constructor_elt, va_gc> *v; { tree name_name, name_string; @@ -935,7 +932,7 @@ tinfo_base_init (tinfo_s *ti, tree target) ti->vtable = vtable_ptr; } - v = VEC_alloc (constructor_elt, gc, 2); + vec_alloc (v, 2); CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, vtable_ptr); CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, decay_conversion (name_decl, tf_warning_or_error)); @@ -973,7 +970,8 @@ ptr_initializer (tinfo_s *ti, tree target) tree to = TREE_TYPE (target); int flags = qualifier_flags (to); bool incomplete = target_incomplete_p (to); - VEC(constructor_elt,gc) *v = VEC_alloc (constructor_elt, gc, 3); + vec<constructor_elt, va_gc> *v; + vec_alloc (v, 3); if (incomplete) flags |= 8; @@ -1001,7 +999,8 @@ ptm_initializer (tinfo_s *ti, tree target) tree klass = TYPE_PTRMEM_CLASS_TYPE (target); int flags = qualifier_flags (to); bool incomplete = target_incomplete_p (to); - VEC(constructor_elt,gc) *v = VEC_alloc (constructor_elt, gc, 4); + vec<constructor_elt, va_gc> *v; + vec_alloc (v, 4); if (incomplete) flags |= 0x8; @@ -1029,7 +1028,8 @@ class_initializer (tinfo_s *ti, tree target, unsigned n, ...) tree init = tinfo_base_init (ti, target); va_list extra_inits; unsigned i; - VEC(constructor_elt,gc) *v = VEC_alloc (constructor_elt, gc, n+1); + vec<constructor_elt, va_gc> *v; + vec_alloc (v, n+1); CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, init); va_start (extra_inits, n); @@ -1079,7 +1079,7 @@ typeinfo_in_lib_p (tree type) static tree get_pseudo_ti_init (tree type, unsigned tk_index) { - tinfo_s *ti = &VEC_index (tinfo_s, tinfo_descs, tk_index); + tinfo_s *ti = &(*tinfo_descs)[tk_index]; gcc_assert (at_eof); switch (tk_index) @@ -1105,7 +1105,7 @@ get_pseudo_ti_init (tree type, unsigned tk_index) tree tinfo = get_tinfo_ptr (BINFO_TYPE (base_binfo)); /* get_tinfo_ptr might have reallocated the tinfo_descs vector. */ - ti = &VEC_index (tinfo_s, tinfo_descs, tk_index); + ti = &(*tinfo_descs)[tk_index]; return class_initializer (ti, type, 1, tinfo); } @@ -1115,16 +1115,16 @@ get_pseudo_ti_init (tree type, unsigned tk_index) | (CLASSTYPE_DIAMOND_SHAPED_P (type) << 1)); tree binfo = TYPE_BINFO (type); int nbases = BINFO_N_BASE_BINFOS (binfo); - VEC(tree,gc) *base_accesses = BINFO_BASE_ACCESSES (binfo); + vec<tree, va_gc> *base_accesses = BINFO_BASE_ACCESSES (binfo); tree offset_type = integer_types[itk_long]; tree base_inits = NULL_TREE; int ix; - VEC(constructor_elt,gc) *init_vec = NULL; + vec<constructor_elt, va_gc> *init_vec = NULL; constructor_elt *e; gcc_assert (tk_index >= TK_FIXED); - VEC_safe_grow (constructor_elt, gc, init_vec, nbases); + vec_safe_grow (init_vec, nbases); /* Generate the base information initializer. */ for (ix = nbases; ix--;) { @@ -1133,9 +1133,9 @@ get_pseudo_ti_init (tree type, unsigned tk_index) int flags = 0; tree tinfo; tree offset; - VEC(constructor_elt,gc) *v; + vec<constructor_elt, va_gc> *v; - if (VEC_index (tree, base_accesses, ix) == access_public_node) + if ((*base_accesses)[ix] == access_public_node) flags |= 2; tinfo = get_tinfo_ptr (BINFO_TYPE (base_binfo)); if (BINFO_VIRTUAL_P (base_binfo)) @@ -1156,18 +1156,18 @@ get_pseudo_ti_init (tree type, unsigned tk_index) offset = fold_build2_loc (input_location, BIT_IOR_EXPR, offset_type, offset, build_int_cst (offset_type, flags)); - v = VEC_alloc (constructor_elt, gc, 2); + vec_alloc (v, 2); CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, tinfo); CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, offset); base_init = build_constructor (init_list_type_node, v); - e = &VEC_index (constructor_elt, init_vec, ix); + e = &(*init_vec)[ix]; e->index = NULL_TREE; e->value = base_init; } base_inits = build_constructor (init_list_type_node, init_vec); /* get_tinfo_ptr might have reallocated the tinfo_descs vector. */ - ti = &VEC_index (tinfo_s, tinfo_descs, tk_index); + ti = &(*tinfo_descs)[tk_index]; return class_initializer (ti, type, 3, build_int_cst (NULL_TREE, hint), build_int_cst (NULL_TREE, nbases), @@ -1213,8 +1213,7 @@ create_pseudo_type_info (int tk, const char *real_name, ...) /* First field is the pseudo type_info base class. */ fields = build_decl (input_location, FIELD_DECL, NULL_TREE, - VEC_index (tinfo_s, tinfo_descs, - TK_TYPE_INFO_TYPE).type); + (*tinfo_descs)[TK_TYPE_INFO_TYPE].type); /* Now add the derived fields. */ while ((field_decl = va_arg (ap, tree))) @@ -1228,7 +1227,7 @@ create_pseudo_type_info (int tk, const char *real_name, ...) finish_builtin_struct (pseudo_type, pseudo_name, fields, NULL_TREE); CLASSTYPE_AS_BASE (pseudo_type) = pseudo_type; - ti = &VEC_index (tinfo_s, tinfo_descs, tk); + ti = &(*tinfo_descs)[tk]; ti->type = cp_build_qualified_type (pseudo_type, TYPE_QUAL_CONST); ti->name = get_identifier (real_name); ti->vtable = NULL_TREE; @@ -1293,12 +1292,12 @@ get_pseudo_ti_index (tree type) else { tree binfo = TYPE_BINFO (type); - VEC(tree,gc) *base_accesses = BINFO_BASE_ACCESSES (binfo); + vec<tree, va_gc> *base_accesses = BINFO_BASE_ACCESSES (binfo); tree base_binfo = BINFO_BASE_BINFO (binfo, 0); int num_bases = BINFO_N_BASE_BINFOS (binfo); if (num_bases == 1 - && VEC_index (tree, base_accesses, 0) == access_public_node + && (*base_accesses)[0] == access_public_node && !BINFO_VIRTUAL_P (base_binfo) && integer_zerop (BINFO_OFFSET (base_binfo))) { @@ -1312,16 +1311,16 @@ get_pseudo_ti_index (tree type) tree array_domain, base_array; ix = TK_FIXED + num_bases; - if (VEC_length (tinfo_s, tinfo_descs) <= ix) + if (vec_safe_length (tinfo_descs) <= ix) { /* too short, extend. */ - unsigned len = VEC_length (tinfo_s, tinfo_descs); + unsigned len = vec_safe_length (tinfo_descs); - VEC_safe_grow (tinfo_s, gc, tinfo_descs, ix + 1); - while (VEC_iterate (tinfo_s, tinfo_descs, len++, ti)) + vec_safe_grow (tinfo_descs, ix + 1); + while (tinfo_descs->iterate (len++, &ti)) ti->type = ti->vtable = ti->name = NULL_TREE; } - else if (VEC_index (tinfo_s, tinfo_descs, ix).type) + else if ((*tinfo_descs)[ix].type) /* already created. */ break; @@ -1333,10 +1332,8 @@ get_pseudo_ti_index (tree type) array_domain = build_index_type (size_int (num_bases - 1)); else array_domain = build_index_type (size_int (num_bases)); - base_array = - build_array_type (VEC_index (tinfo_s, tinfo_descs, - TK_BASE_TYPE).type, - array_domain); + base_array = build_array_type ((*tinfo_descs)[TK_BASE_TYPE].type, + array_domain); push_abi_namespace (); create_pseudo_type_info @@ -1369,7 +1366,7 @@ create_tinfo_types (void) gcc_assert (!tinfo_descs); - VEC_safe_grow (tinfo_s, gc, tinfo_descs, TK_FIXED); + vec_safe_grow (tinfo_descs, TK_FIXED); push_abi_namespace (); @@ -1387,7 +1384,7 @@ create_tinfo_types (void) DECL_CHAIN (field) = fields; fields = field; - ti = &VEC_index (tinfo_s, tinfo_descs, TK_TYPE_INFO_TYPE); + ti = &(*tinfo_descs)[TK_TYPE_INFO_TYPE]; ti->type = make_class_type (RECORD_TYPE); ti->vtable = NULL_TREE; ti->name = NULL_TREE; @@ -1427,7 +1424,7 @@ create_tinfo_types (void) DECL_CHAIN (field) = fields; fields = field; - ti = &VEC_index (tinfo_s, tinfo_descs, TK_BASE_TYPE); + ti = &(*tinfo_descs)[TK_BASE_TYPE]; ti->type = make_class_type (RECORD_TYPE); ti->vtable = NULL_TREE; diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 1614f49..92234a5 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -639,14 +639,14 @@ dfs_access_in_type (tree binfo, void *data) { int i; tree base_binfo; - VEC(tree,gc) *accesses; + vec<tree, va_gc> *accesses; /* Otherwise, scan our baseclasses, and pick the most favorable access. */ accesses = BINFO_BASE_ACCESSES (binfo); for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++) { - tree base_access = VEC_index (tree, accesses, i); + tree base_access = (*accesses)[i]; access_kind base_access_now = BINFO_ACCESS (base_binfo); if (base_access_now == ak_none || base_access_now == ak_private) @@ -1316,10 +1316,10 @@ lookup_conversion_operator (tree class_type, tree type) { int i; tree fn; - VEC(tree,gc) *methods = CLASSTYPE_METHOD_VEC (class_type); + vec<tree, va_gc> *methods = CLASSTYPE_METHOD_VEC (class_type); for (i = CLASSTYPE_FIRST_CONVERSION_SLOT; - VEC_iterate (tree, methods, i, fn); ++i) + vec_safe_iterate (methods, i, &fn); ++i) { /* All the conversion operators come near the beginning of the class. Therefore, if FN is not a conversion @@ -1348,7 +1348,7 @@ lookup_conversion_operator (tree class_type, tree type) static int lookup_fnfields_idx_nolazy (tree type, tree name) { - VEC(tree,gc) *method_vec; + vec<tree, va_gc> *method_vec; tree fn; tree tmp; size_t i; @@ -1380,7 +1380,7 @@ lookup_fnfields_idx_nolazy (tree type, tree name) /* Skip the conversion operators. */ for (i = CLASSTYPE_FIRST_CONVERSION_SLOT; - VEC_iterate (tree, method_vec, i, fn); + vec_safe_iterate (method_vec, i, &fn); ++i) if (!DECL_CONV_FN_P (OVL_CURRENT (fn))) break; @@ -1392,7 +1392,7 @@ lookup_fnfields_idx_nolazy (tree type, tree name) int hi; lo = i; - hi = VEC_length (tree, method_vec); + hi = method_vec->length (); while (lo < hi) { i = (lo + hi) / 2; @@ -1400,7 +1400,7 @@ lookup_fnfields_idx_nolazy (tree type, tree name) if (GATHER_STATISTICS) n_outer_fields_searched++; - tmp = VEC_index (tree, method_vec, i); + tmp = (*method_vec)[i]; tmp = DECL_NAME (OVL_CURRENT (tmp)); if (tmp > name) hi = i; @@ -1411,7 +1411,7 @@ lookup_fnfields_idx_nolazy (tree type, tree name) } } else - for (; VEC_iterate (tree, method_vec, i, fn); ++i) + for (; vec_safe_iterate (method_vec, i, &fn); ++i) { if (GATHER_STATISTICS) n_outer_fields_searched++; @@ -1471,7 +1471,7 @@ lookup_fnfields_slot (tree type, tree name) int ix = lookup_fnfields_1 (complete_type (type), name); if (ix < 0) return NULL_TREE; - return VEC_index (tree, CLASSTYPE_METHOD_VEC (type), ix); + return (*CLASSTYPE_METHOD_VEC (type))[ix]; } /* As above, but avoid lazily declaring functions. */ @@ -1482,7 +1482,7 @@ lookup_fnfields_slot_nolazy (tree type, tree name) int ix = lookup_fnfields_idx_nolazy (complete_type (type), name); if (ix < 0) return NULL_TREE; - return VEC_index (tree, CLASSTYPE_METHOD_VEC (type), ix); + return (*CLASSTYPE_METHOD_VEC (type))[ix]; } /* Like lookup_fnfields_1, except that the name is extracted from @@ -1701,12 +1701,12 @@ dfs_walk_once (tree binfo, tree (*pre_fn) (tree, void *), /* We are at the top of the hierarchy, and can use the CLASSTYPE_VBASECLASSES list for unmarking the virtual bases. */ - VEC(tree,gc) *vbases; + vec<tree, va_gc> *vbases; unsigned ix; tree base_binfo; for (vbases = CLASSTYPE_VBASECLASSES (BINFO_TYPE (binfo)), ix = 0; - VEC_iterate (tree, vbases, ix, base_binfo); ix++) + vec_safe_iterate (vbases, ix, &base_binfo); ix++) BINFO_MARKED (base_binfo) = 0; } else @@ -1809,12 +1809,12 @@ dfs_walk_once_accessible (tree binfo, bool friends_p, /* We are at the top of the hierarchy, and can use the CLASSTYPE_VBASECLASSES list for unmarking the virtual bases. */ - VEC(tree,gc) *vbases; + vec<tree, va_gc> *vbases; unsigned ix; tree base_binfo; for (vbases = CLASSTYPE_VBASECLASSES (BINFO_TYPE (binfo)), ix = 0; - VEC_iterate (tree, vbases, ix, base_binfo); ix++) + vec_safe_iterate (vbases, ix, &base_binfo); ix++) BINFO_MARKED (base_binfo) = 0; } else @@ -2019,7 +2019,7 @@ look_for_overrides_here (tree type, tree fndecl) ix = lookup_fnfields_1 (type, DECL_NAME (fndecl)); if (ix >= 0) { - tree fns = VEC_index (tree, CLASSTYPE_METHOD_VEC (type), ix); + tree fns = (*CLASSTYPE_METHOD_VEC (type))[ix]; for (; fns; fns = OVL_NEXT (fns)) { @@ -2090,8 +2090,7 @@ dfs_get_pure_virtuals (tree binfo, void *data) virtuals; virtuals = TREE_CHAIN (virtuals)) if (DECL_PURE_VIRTUAL_P (BV_FN (virtuals))) - VEC_safe_push (tree, gc, CLASSTYPE_PURE_VIRTUALS (type), - BV_FN (virtuals)); + vec_safe_push (CLASSTYPE_PURE_VIRTUALS (type), BV_FN (virtuals)); } return NULL_TREE; @@ -2364,7 +2363,7 @@ lookup_conversions_r (tree binfo, tree child_tpl_convs = NULL_TREE; unsigned i; tree base_binfo; - VEC(tree,gc) *method_vec = CLASSTYPE_METHOD_VEC (BINFO_TYPE (binfo)); + vec<tree, va_gc> *method_vec = CLASSTYPE_METHOD_VEC (BINFO_TYPE (binfo)); tree conv; /* If we have no conversion operators, then don't look. */ @@ -2380,7 +2379,7 @@ lookup_conversions_r (tree binfo, /* First, locate the unhidden ones at this level. */ for (i = CLASSTYPE_FIRST_CONVERSION_SLOT; - VEC_iterate (tree, method_vec, i, conv); + vec_safe_iterate (method_vec, i, &conv); ++i) { tree cur = OVL_CURRENT (conv); @@ -2622,10 +2621,10 @@ binfo_for_vbase (tree base, tree t) { unsigned ix; tree binfo; - VEC(tree,gc) *vbases; + vec<tree, va_gc> *vbases; for (vbases = CLASSTYPE_VBASECLASSES (t), ix = 0; - VEC_iterate (tree, vbases, ix, binfo); ix++) + vec_safe_iterate (vbases, ix, &binfo); ix++) if (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), base)) return binfo; return NULL; diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index de6461c..bbafa3a 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -92,7 +92,7 @@ static tree capture_decltype (tree); 2. When a declaration such as a type, or a variable, is encountered, the function `perform_or_defer_access_check' is called. It - maintains a VEC of all deferred checks. + maintains a vector of all deferred checks. 3. The global `current_class_type' or `current_function_decl' is then setup by the parser. `enforce_access' relies on these information @@ -100,14 +100,14 @@ static tree capture_decltype (tree); 4. Upon exiting the context mentioned in step 1, `perform_deferred_access_checks' is called to check all declaration - stored in the VEC. `pop_deferring_access_checks' is then + stored in the vector. `pop_deferring_access_checks' is then called to restore the previous access checking mode. In case of parsing error, we simply call `pop_deferring_access_checks' without `perform_deferred_access_checks'. */ typedef struct GTY(()) deferred_access { - /* A VEC representing name-lookups for which we have deferred + /* A vector representing name-lookups for which we have deferred checking access controls. We cannot check the accessibility of names used in a decl-specifier-seq until we know what is being declared because code like: @@ -120,17 +120,15 @@ typedef struct GTY(()) deferred_access { A::B* A::f() { return 0; } is valid, even though `A::B' is not generally accessible. */ - VEC (deferred_access_check,gc)* GTY(()) deferred_access_checks; + vec<deferred_access_check, va_gc> * GTY(()) deferred_access_checks; /* The current mode of access checks. */ enum deferring_kind deferring_access_checks_kind; } deferred_access; -DEF_VEC_O (deferred_access); -DEF_VEC_ALLOC_O (deferred_access,gc); /* Data for deferred access checking. */ -static GTY(()) VEC(deferred_access,gc) *deferred_access_stack; +static GTY(()) vec<deferred_access, va_gc> *deferred_access_stack; static GTY(()) unsigned deferred_access_no_check; /* Save the current deferred access states and start deferred @@ -146,7 +144,7 @@ push_deferring_access_checks (deferring_kind deferring) else { deferred_access e = {NULL, deferring}; - VEC_safe_push (deferred_access, gc, deferred_access_stack, e); + vec_safe_push (deferred_access_stack, e); } } @@ -157,8 +155,7 @@ void resume_deferring_access_checks (void) { if (!deferred_access_no_check) - VEC_last (deferred_access, deferred_access_stack) - .deferring_access_checks_kind = dk_deferred; + deferred_access_stack->last().deferring_access_checks_kind = dk_deferred; } /* Stop deferring access checks. */ @@ -167,8 +164,7 @@ void stop_deferring_access_checks (void) { if (!deferred_access_no_check) - VEC_last (deferred_access, deferred_access_stack) - .deferring_access_checks_kind = dk_no_deferred; + deferred_access_stack->last().deferring_access_checks_kind = dk_no_deferred; } /* Discard the current deferred access checks and restore the @@ -180,7 +176,7 @@ pop_deferring_access_checks (void) if (deferred_access_no_check) deferred_access_no_check--; else - VEC_pop (deferred_access, deferred_access_stack); + deferred_access_stack->pop (); } /* Returns a TREE_LIST representing the deferred checks. @@ -188,14 +184,13 @@ pop_deferring_access_checks (void) access occurred; the TREE_VALUE is the declaration named. */ -VEC (deferred_access_check,gc)* +vec<deferred_access_check, va_gc> * get_deferred_access_checks (void) { if (deferred_access_no_check) return NULL; else - return (VEC_last (deferred_access, deferred_access_stack) - .deferred_access_checks); + return (deferred_access_stack->last().deferred_access_checks); } /* Take current deferred checks and combine with the @@ -209,14 +204,13 @@ pop_to_parent_deferring_access_checks (void) deferred_access_no_check--; else { - VEC (deferred_access_check,gc) *checks; + vec<deferred_access_check, va_gc> *checks; deferred_access *ptr; - checks = (VEC_last (deferred_access, deferred_access_stack) - .deferred_access_checks); + checks = (deferred_access_stack->last ().deferred_access_checks); - VEC_pop (deferred_access, deferred_access_stack); - ptr = &VEC_last (deferred_access, deferred_access_stack); + deferred_access_stack->pop (); + ptr = &deferred_access_stack->last (); if (ptr->deferring_access_checks_kind == dk_no_deferred) { /* Check access. */ @@ -228,10 +222,9 @@ pop_to_parent_deferring_access_checks (void) int i, j; deferred_access_check *chk, *probe; - FOR_EACH_VEC_ELT (deferred_access_check, checks, i, chk) + FOR_EACH_VEC_SAFE_ELT (checks, i, chk) { - FOR_EACH_VEC_ELT (deferred_access_check, - ptr->deferred_access_checks, j, probe) + FOR_EACH_VEC_SAFE_ELT (ptr->deferred_access_checks, j, probe) { if (probe->binfo == chk->binfo && probe->decl == chk->decl && @@ -239,8 +232,7 @@ pop_to_parent_deferring_access_checks (void) goto found; } /* Insert into parent's checks. */ - VEC_safe_push (deferred_access_check, gc, - ptr->deferred_access_checks, *chk); + vec_safe_push (ptr->deferred_access_checks, *chk); found:; } } @@ -254,7 +246,7 @@ pop_to_parent_deferring_access_checks (void) otherwise FALSE. */ bool -perform_access_checks (VEC (deferred_access_check,gc)* checks, +perform_access_checks (vec<deferred_access_check, va_gc> *checks, tsubst_flags_t complain) { int i; @@ -265,7 +257,7 @@ perform_access_checks (VEC (deferred_access_check,gc)* checks, if (!checks) return true; - FOR_EACH_VEC_ELT (deferred_access_check, checks, i, chk) + FOR_EACH_VEC_SAFE_ELT (checks, i, chk) { input_location = chk->loc; ok &= enforce_access (chk->binfo, chk->decl, chk->diag_decl, complain); @@ -317,7 +309,7 @@ perform_or_defer_access_check (tree binfo, tree decl, tree diag_decl, gcc_assert (TREE_CODE (binfo) == TREE_BINFO); - ptr = &VEC_last (deferred_access, deferred_access_stack); + ptr = &deferred_access_stack->last (); /* If we are not supposed to defer access checks, just check now. */ if (ptr->deferring_access_checks_kind == dk_no_deferred) @@ -327,8 +319,7 @@ perform_or_defer_access_check (tree binfo, tree decl, tree diag_decl, } /* See if we are already going to perform this check. */ - FOR_EACH_VEC_ELT (deferred_access_check, - ptr->deferred_access_checks, i, chk) + FOR_EACH_VEC_SAFE_ELT (ptr->deferred_access_checks, i, chk) { if (chk->decl == decl && chk->binfo == binfo && chk->diag_decl == diag_decl) @@ -338,8 +329,7 @@ perform_or_defer_access_check (tree binfo, tree decl, tree diag_decl, } /* If not, record the check. */ deferred_access_check new_access = {binfo, decl, diag_decl, input_location}; - VEC_safe_push (deferred_access_check, gc, ptr->deferred_access_checks, - new_access); + vec_safe_push (ptr->deferred_access_checks, new_access); return true; } @@ -375,7 +365,7 @@ add_stmt (tree t) /* Add T to the statement-tree. Non-side-effect statements need to be recorded during statement expressions. */ - gcc_checking_assert (!VEC_empty (tree, stmt_list_stack)); + gcc_checking_assert (!stmt_list_stack->is_empty ()); append_to_statement_list_force (t, &cur_stmt_list); return t; @@ -1972,7 +1962,7 @@ empty_expr_stmt_p (tree expr_stmt) Returns the functions to be considered by overload resolution. */ tree -perform_koenig_lookup (tree fn, VEC(tree,gc) *args, bool include_std, +perform_koenig_lookup (tree fn, vec<tree, va_gc> *args, bool include_std, tsubst_flags_t complain) { tree identifier = NULL_TREE; @@ -2038,12 +2028,12 @@ perform_koenig_lookup (tree fn, VEC(tree,gc) *args, bool include_std, Returns code for the call. */ tree -finish_call_expr (tree fn, VEC(tree,gc) **args, bool disallow_virtual, +finish_call_expr (tree fn, vec<tree, va_gc> **args, bool disallow_virtual, bool koenig_p, tsubst_flags_t complain) { tree result; tree orig_fn; - VEC(tree,gc) *orig_args = NULL; + vec<tree, va_gc> *orig_args = NULL; if (fn == error_mark_node) return error_mark_node; @@ -2172,7 +2162,7 @@ finish_call_expr (tree fn, VEC(tree,gc) **args, bool disallow_virtual, if (!result) { if (warn_sizeof_pointer_memaccess - && !VEC_empty(tree, *args) + && !vec_safe_is_empty (*args) && !processing_template_decl) { location_t sizeof_arg_loc[3]; @@ -2184,9 +2174,9 @@ finish_call_expr (tree fn, VEC(tree,gc) **args, bool disallow_virtual, sizeof_arg_loc[i] = UNKNOWN_LOCATION; sizeof_arg[i] = NULL_TREE; - if (i >= VEC_length (tree, *args)) + if (i >= (*args)->length ()) continue; - t = VEC_index (tree, *args, i); + t = (**args)[i]; if (TREE_CODE (t) != SIZEOF_EXPR) continue; if (SIZEOF_EXPR_TYPE_P (t)) @@ -2206,7 +2196,7 @@ finish_call_expr (tree fn, VEC(tree,gc) **args, bool disallow_virtual, } else if (TREE_CODE (fn) == PSEUDO_DTOR_EXPR) { - if (!VEC_empty (tree, *args)) + if (!vec_safe_is_empty (*args)) error ("arguments to destructor are not allowed"); /* Mark the pseudo-destructor call as having side-effects so that we do not issue warnings about its use. */ @@ -3448,9 +3438,9 @@ finish_underlying_type (tree type) tree calculate_direct_bases (tree type) { - VEC(tree, gc) *vector = make_tree_vector(); + vec<tree, va_gc> *vector = make_tree_vector(); tree bases_vec = NULL_TREE; - VEC(tree, none) *base_binfos; + vec<tree, va_gc> *base_binfos; tree binfo; unsigned i; @@ -3462,29 +3452,29 @@ calculate_direct_bases (tree type) base_binfos = BINFO_BASE_BINFOS (TYPE_BINFO (type)); /* Virtual bases are initialized first */ - for (i = 0; VEC_iterate (tree, base_binfos, i, binfo); i++) + for (i = 0; base_binfos->iterate (i, &binfo); i++) { if (BINFO_VIRTUAL_P (binfo)) { - VEC_safe_push (tree, gc, vector, binfo); + vec_safe_push (vector, binfo); } } /* Now non-virtuals */ - for (i = 0; VEC_iterate (tree, base_binfos, i, binfo); i++) + for (i = 0; base_binfos->iterate (i, &binfo); i++) { if (!BINFO_VIRTUAL_P (binfo)) { - VEC_safe_push (tree, gc, vector, binfo); + vec_safe_push (vector, binfo); } } - bases_vec = make_tree_vec (VEC_length (tree, vector)); + bases_vec = make_tree_vec (vector->length ()); - for (i = 0; i < VEC_length (tree, vector); ++i) + for (i = 0; i < vector->length (); ++i) { - TREE_VEC_ELT (bases_vec, i) = BINFO_TYPE (VEC_index (tree, vector, i)); + TREE_VEC_ELT (bases_vec, i) = BINFO_TYPE ((*vector)[i]); } return bases_vec; } @@ -3505,19 +3495,19 @@ dfs_calculate_bases_pre (tree binfo, void * /*data_*/) static tree dfs_calculate_bases_post (tree binfo, void *data_) { - VEC(tree, gc) **data = (VEC(tree, gc) **) data_; + vec<tree, va_gc> **data = ((vec<tree, va_gc> **) data_); if (!BINFO_VIRTUAL_P (binfo)) { - VEC_safe_push (tree, gc, *data, BINFO_TYPE (binfo)); + vec_safe_push (*data, BINFO_TYPE (binfo)); } return NULL_TREE; } /* Calculates the morally non-virtual base classes of a class */ -static VEC(tree, gc) * +static vec<tree, va_gc> * calculate_bases_helper (tree type) { - VEC(tree, gc) *vector = make_tree_vector(); + vec<tree, va_gc> *vector = make_tree_vector(); /* Now add non-virtual base classes in order of construction */ dfs_walk_all (TYPE_BINFO (type), @@ -3528,11 +3518,11 @@ calculate_bases_helper (tree type) tree calculate_bases (tree type) { - VEC(tree, gc) *vector = make_tree_vector(); + vec<tree, va_gc> *vector = make_tree_vector(); tree bases_vec = NULL_TREE; unsigned i; - VEC(tree, gc) *vbases; - VEC(tree, gc) *nonvbases; + vec<tree, va_gc> *vbases; + vec<tree, va_gc> *nonvbases; tree binfo; complete_type (type); @@ -3542,24 +3532,25 @@ calculate_bases (tree type) /* First go through virtual base classes */ for (vbases = CLASSTYPE_VBASECLASSES (type), i = 0; - VEC_iterate (tree, vbases, i, binfo); i++) + vec_safe_iterate (vbases, i, &binfo); i++) { - VEC(tree, gc) *vbase_bases = calculate_bases_helper (BINFO_TYPE (binfo)); - VEC_safe_splice (tree, gc, vector, vbase_bases); + vec<tree, va_gc> *vbase_bases; + vbase_bases = calculate_bases_helper (BINFO_TYPE (binfo)); + vec_safe_splice (vector, vbase_bases); release_tree_vector (vbase_bases); } /* Now for the non-virtual bases */ nonvbases = calculate_bases_helper (type); - VEC_safe_splice (tree, gc, vector, nonvbases); + vec_safe_splice (vector, nonvbases); release_tree_vector (nonvbases); /* Last element is entire class, so don't copy */ - bases_vec = make_tree_vec (VEC_length (tree, vector) - 1); + bases_vec = make_tree_vec (vector->length () - 1); - for (i = 0; i < VEC_length (tree, vector) - 1; ++i) + for (i = 0; i < vector->length () - 1; ++i) { - TREE_VEC_ELT (bases_vec, i) = VEC_index (tree, vector, i); + TREE_VEC_ELT (bases_vec, i) = (*vector)[i]; } release_tree_vector (vector); return bases_vec; @@ -5010,7 +5001,7 @@ void finish_omp_barrier (void) { tree fn = builtin_decl_explicit (BUILT_IN_GOMP_BARRIER); - VEC(tree,gc) *vec = make_tree_vector (); + vec<tree, va_gc> *vec = make_tree_vector (); tree stmt = finish_call_expr (fn, &vec, false, false, tf_warning_or_error); release_tree_vector (vec); finish_expr_stmt (stmt); @@ -5020,7 +5011,7 @@ void finish_omp_flush (void) { tree fn = builtin_decl_explicit (BUILT_IN_SYNC_SYNCHRONIZE); - VEC(tree,gc) *vec = make_tree_vector (); + vec<tree, va_gc> *vec = make_tree_vector (); tree stmt = finish_call_expr (fn, &vec, false, false, tf_warning_or_error); release_tree_vector (vec); finish_expr_stmt (stmt); @@ -5030,7 +5021,7 @@ void finish_omp_taskwait (void) { tree fn = builtin_decl_explicit (BUILT_IN_GOMP_TASKWAIT); - VEC(tree,gc) *vec = make_tree_vector (); + vec<tree, va_gc> *vec = make_tree_vector (); tree stmt = finish_call_expr (fn, &vec, false, false, tf_warning_or_error); release_tree_vector (vec); finish_expr_stmt (stmt); @@ -5040,7 +5031,7 @@ void finish_omp_taskyield (void) { tree fn = builtin_decl_explicit (BUILT_IN_GOMP_TASKYIELD); - VEC(tree,gc) *vec = make_tree_vector (); + vec<tree, va_gc> *vec = make_tree_vector (); tree stmt = finish_call_expr (fn, &vec, false, false, tf_warning_or_error); release_tree_vector (vec); finish_expr_stmt (stmt); @@ -5380,7 +5371,7 @@ classtype_has_nothrow_assign_or_copy_p (tree type, bool assign_p) ix = lookup_fnfields_1 (type, ansi_assopname (NOP_EXPR)); if (ix < 0) return false; - fns = VEC_index (tree, CLASSTYPE_METHOD_VEC (type), ix); + fns = (*CLASSTYPE_METHOD_VEC (type))[ix]; } else if (TYPE_HAS_COPY_CTOR (type)) { @@ -5806,7 +5797,7 @@ is_valid_constexpr_fn (tree fun, bool complain) to the existing initialization pair INITS. */ static bool -build_data_member_initialization (tree t, VEC(constructor_elt,gc) **vec) +build_data_member_initialization (tree t, vec<constructor_elt, va_gc> **vec) { tree member, init; if (TREE_CODE (t) == CLEANUP_POINT_EXPR) @@ -5933,13 +5924,13 @@ check_constexpr_ctor_body (tree last, tree list) return ok; } -/* VEC is a vector of constructor elements built up for the base and member +/* V is a vector of constructor elements built up for the base and member initializers of a constructor for TYPE. They need to be in increasing offset order, which they might not be yet if TYPE has a primary base which is not first in the base-clause. */ -static VEC(constructor_elt,gc) * -sort_constexpr_mem_initializers (tree type, VEC(constructor_elt,gc) *vec) +static vec<constructor_elt, va_gc> * +sort_constexpr_mem_initializers (tree type, vec<constructor_elt, va_gc> *v) { tree pri = CLASSTYPE_PRIMARY_BINFO (type); constructor_elt elt; @@ -5947,21 +5938,21 @@ sort_constexpr_mem_initializers (tree type, VEC(constructor_elt,gc) *vec) if (pri == NULL_TREE || pri == BINFO_BASE_BINFO (TYPE_BINFO (type), 0)) - return vec; + return v; /* Find the element for the primary base and move it to the beginning of the vec. */ - VEC(constructor_elt,gc) &v = *vec; + vec<constructor_elt, va_gc> &vref = *v; pri = BINFO_TYPE (pri); for (i = 1; ; ++i) - if (TREE_TYPE (v[i].index) == pri) + if (TREE_TYPE (vref[i].index) == pri) break; - elt = v[i]; + elt = vref[i]; for (; i > 0; --i) - v[i] = v[i-1]; - v[0] = elt; - return vec; + vref[i] = vref[i-1]; + vref[0] = elt; + return v; } /* Build compile-time evalable representations of member-initializer list @@ -5970,7 +5961,7 @@ sort_constexpr_mem_initializers (tree type, VEC(constructor_elt,gc) *vec) static tree build_constexpr_constructor_member_initializers (tree type, tree body) { - VEC(constructor_elt,gc) *vec = NULL; + vec<constructor_elt, va_gc> *vec = NULL; bool ok = true; if (TREE_CODE (body) == MUST_NOT_THROW_EXPR || TREE_CODE (body) == EH_SPEC_BLOCK) @@ -6015,14 +6006,14 @@ build_constexpr_constructor_member_initializers (tree type, tree body) gcc_assert (errorcount > 0); if (ok) { - if (VEC_length (constructor_elt, vec) > 0) + if (vec_safe_length (vec) > 0) { /* In a delegating constructor, return the target. */ - constructor_elt *ce = &VEC_index (constructor_elt, vec, 0); + constructor_elt *ce = &(*vec)[0]; if (ce->index == current_class_ptr) { body = ce->value; - VEC_free (constructor_elt, gc, vec); + vec_free (vec); return body; } } @@ -6519,7 +6510,7 @@ cxx_bind_parameters_in_call (const constexpr_call *old_call, tree t, These do not need to be marked for PCH or GC. */ /* FIXME remember and print actual constant arguments. */ -static VEC(tree,heap) *call_stack = NULL; +static vec<tree> call_stack = vec<tree>(); static int call_stack_tick; static int last_cx_error_tick; @@ -6529,8 +6520,8 @@ push_cx_call_context (tree call) ++call_stack_tick; if (!EXPR_HAS_LOCATION (call)) SET_EXPR_LOCATION (call, input_location); - VEC_safe_push (tree, heap, call_stack, call); - if (VEC_length (tree, call_stack) > (unsigned) max_constexpr_depth) + call_stack.safe_push (call); + if (call_stack.length () > (unsigned) max_constexpr_depth) return false; return true; } @@ -6539,15 +6530,15 @@ static void pop_cx_call_context (void) { ++call_stack_tick; - VEC_pop (tree, call_stack); + call_stack.pop (); } -VEC(tree,heap) * +vec<tree> cx_error_context (void) { - VEC(tree,heap) *r = NULL; + vec<tree> r = vec<tree>(); if (call_stack_tick != last_cx_error_tick - && !VEC_empty (tree, call_stack)) + && !call_stack.is_empty ()) r = call_stack; last_cx_error_tick = call_stack_tick; return r; @@ -6893,7 +6884,7 @@ cxx_eval_array_reference (const constexpr_call *call, tree t, } i = tree_low_cst (index, 0); if (TREE_CODE (ary) == CONSTRUCTOR) - return VEC_index (constructor_elt, CONSTRUCTOR_ELTS (ary), i).value; + return (*CONSTRUCTOR_ELTS (ary))[i].value; else if (elem_nchars == 1) return build_int_cst (cv_unqualified (TREE_TYPE (TREE_TYPE (ary))), TREE_STRING_POINTER (ary)[i]); @@ -7076,7 +7067,7 @@ cxx_eval_logical_expression (const constexpr_call *call, tree t, initialization of the field. */ static constructor_elt * -base_field_constructor_elt (VEC(constructor_elt,gc) *v, tree ref) +base_field_constructor_elt (vec<constructor_elt, va_gc> *v, tree ref) { tree aggr = TREE_OPERAND (ref, 0); tree field = TREE_OPERAND (ref, 1); @@ -7092,7 +7083,7 @@ base_field_constructor_elt (VEC(constructor_elt,gc) *v, tree ref) v = CONSTRUCTOR_ELTS (base_ce->value); } - for (i = 0; VEC_iterate (constructor_elt, v, i, ce); ++i) + for (i = 0; vec_safe_iterate (v, i, &ce); ++i) if (ce->index == field) return ce; @@ -7109,14 +7100,14 @@ cxx_eval_bare_aggregate (const constexpr_call *call, tree t, bool allow_non_constant, bool addr, bool *non_constant_p) { - VEC(constructor_elt,gc) *v = CONSTRUCTOR_ELTS (t); - VEC(constructor_elt,gc) *n = VEC_alloc (constructor_elt, gc, - VEC_length (constructor_elt, v)); + vec<constructor_elt, va_gc> *v = CONSTRUCTOR_ELTS (t); + vec<constructor_elt, va_gc> *n; + vec_alloc (n, vec_safe_length (v)); constructor_elt *ce; HOST_WIDE_INT i; bool changed = false; gcc_assert (!BRACE_ENCLOSED_INITIALIZER_P (t)); - for (i = 0; VEC_iterate (constructor_elt, v, i, ce); ++i) + for (i = 0; vec_safe_iterate (v, i, &ce); ++i) { tree elt = cxx_eval_constant_expression (call, ce->value, allow_non_constant, addr, @@ -7146,7 +7137,7 @@ cxx_eval_bare_aggregate (const constexpr_call *call, tree t, if (*non_constant_p || !changed) { fail: - VEC_free (constructor_elt, gc, n); + vec_free (n); return t; } t = build_constructor (TREE_TYPE (t), n); @@ -7173,7 +7164,8 @@ cxx_eval_vec_init_1 (const constexpr_call *call, tree atype, tree init, { tree elttype = TREE_TYPE (atype); int max = tree_low_cst (array_type_nelts (atype), 0); - VEC(constructor_elt,gc) *n = VEC_alloc (constructor_elt, gc, max + 1); + vec<constructor_elt, va_gc> *n; + vec_alloc (n, max + 1); bool pre_init = false; int i; @@ -7193,7 +7185,7 @@ cxx_eval_vec_init_1 (const constexpr_call *call, tree atype, tree init, } else if (!init) { - VEC(tree,gc) *argvec = make_tree_vector (); + vec<tree, va_gc> *argvec = make_tree_vector (); init = build_special_member_call (NULL_TREE, complete_ctor_identifier, &argvec, elttype, LOOKUP_NORMAL, tf_warning_or_error); @@ -7234,7 +7226,7 @@ cxx_eval_vec_init_1 (const constexpr_call *call, tree atype, tree init, else { /* Copying an element. */ - VEC(tree,gc) *argvec; + vec<tree, va_gc> *argvec; gcc_assert (same_type_ignoring_top_level_qualifiers_p (atype, TREE_TYPE (init))); eltinit = cp_build_array_ref (input_location, init, idx, @@ -7242,7 +7234,7 @@ cxx_eval_vec_init_1 (const constexpr_call *call, tree atype, tree init, if (!real_lvalue_p (init)) eltinit = move (eltinit); argvec = make_tree_vector (); - VEC_quick_push (tree, argvec, eltinit); + argvec->quick_push (eltinit); eltinit = (build_special_member_call (NULL_TREE, complete_ctor_identifier, &argvec, elttype, LOOKUP_NORMAL, tf_warning_or_error)); @@ -7263,7 +7255,7 @@ cxx_eval_vec_init_1 (const constexpr_call *call, tree atype, tree init, } fail: - VEC_free (constructor_elt, gc, n); + vec_free (n); return init; } @@ -8517,9 +8509,9 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags) case CONSTRUCTOR: { - VEC(constructor_elt, gc) *v = CONSTRUCTOR_ELTS (t); + vec<constructor_elt, va_gc> *v = CONSTRUCTOR_ELTS (t); constructor_elt *ce; - for (i = 0; VEC_iterate (constructor_elt, v, i, ce); ++i) + for (i = 0; vec_safe_iterate (v, i, &ce); ++i) if (!potential_constant_expression_1 (ce->value, want_rval, flags)) return false; return true; @@ -8747,7 +8739,7 @@ build_lambda_object (tree lambda_expr) /* Build aggregate constructor call. - cp_parser_braced_list - cp_parser_functional_cast */ - VEC(constructor_elt,gc) *elts = NULL; + vec<constructor_elt, va_gc> *elts = NULL; tree node, expr, type; location_t saved_loc; @@ -9067,8 +9059,7 @@ insert_capture_proxy (tree var) /* And put a DECL_EXPR in the STATEMENT_LIST for the same block. */ var = build_stmt (DECL_SOURCE_LOCATION (var), DECL_EXPR, var); - stmt_list = VEC_index (tree, stmt_list_stack, - VEC_length (tree, stmt_list_stack) - 1 - skip); + stmt_list = (*stmt_list_stack)[stmt_list_stack->length () - 1 - skip]; gcc_assert (stmt_list); append_to_statement_list_force (var, &stmt_list); } @@ -9081,7 +9072,7 @@ void insert_pending_capture_proxies (void) { tree lam; - VEC(tree,gc) *proxies; + vec<tree, va_gc> *proxies; unsigned i; if (!current_function_decl || !LAMBDA_FUNCTION_P (current_function_decl)) @@ -9089,9 +9080,9 @@ insert_pending_capture_proxies (void) lam = CLASSTYPE_LAMBDA_EXPR (DECL_CONTEXT (current_function_decl)); proxies = LAMBDA_EXPR_PENDING_PROXIES (lam); - for (i = 0; i < VEC_length (tree, proxies); ++i) + for (i = 0; i < vec_safe_length (proxies); ++i) { - tree var = VEC_index (tree, proxies, i); + tree var = (*proxies)[i]; insert_capture_proxy (var); } release_tree_vector (LAMBDA_EXPR_PENDING_PROXIES (lam)); @@ -9158,7 +9149,7 @@ build_capture_proxy (tree member) if (fn == current_function_decl) insert_capture_proxy (var); else - VEC_safe_push (tree, gc, LAMBDA_EXPR_PENDING_PROXIES (lam), var); + vec_safe_push (LAMBDA_EXPR_PENDING_PROXIES (lam), var); return var; } @@ -9405,7 +9396,7 @@ maybe_add_lambda_conv_op (tree type) tree callop = lambda_function (type); tree rettype, name, fntype, fn, body, compound_stmt; tree thistype, stattype, statfn, convfn, call, arg; - VEC (tree, gc) *argvec; + vec<tree, va_gc> *argvec; if (LAMBDA_EXPR_CAPTURE_LIST (CLASSTYPE_LAMBDA_EXPR (type)) != NULL_TREE) return; @@ -9495,14 +9486,13 @@ maybe_add_lambda_conv_op (tree type) arg = build1 (NOP_EXPR, TREE_TYPE (DECL_ARGUMENTS (callop)), null_pointer_node); argvec = make_tree_vector (); - VEC_quick_push (tree, argvec, arg); + argvec->quick_push (arg); for (arg = DECL_ARGUMENTS (statfn); arg; arg = DECL_CHAIN (arg)) { mark_exp_read (arg); - VEC_safe_push (tree, gc, argvec, arg); + vec_safe_push (argvec, arg); } - call = build_call_a (callop, VEC_length (tree, argvec), - VEC_address (tree, argvec)); + call = build_call_a (callop, argvec->length (), argvec->address ()); CALL_FROM_THUNK_P (call) = 1; if (MAYBE_CLASS_TYPE_P (TREE_TYPE (call))) call = build_cplus_new (TREE_TYPE (call), call, tf_warning_or_error); diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index bc81dac..58725f3 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -508,7 +508,7 @@ static tree build_vec_init_elt (tree type, tree init, tsubst_flags_t complain) { tree inner_type = strip_array_types (type); - VEC(tree,gc) *argvec; + vec<tree, va_gc> *argvec; if (integer_zerop (array_type_nelts_total (type)) || !CLASS_TYPE_P (inner_type)) @@ -527,7 +527,7 @@ build_vec_init_elt (tree type, tree init, tsubst_flags_t complain) tree dummy = build_dummy_object (inner_type); if (!real_lvalue_p (init)) dummy = move (dummy); - VEC_quick_push (tree, argvec, dummy); + argvec->quick_push (dummy); } init = build_special_member_call (NULL_TREE, complete_ctor_identifier, &argvec, inner_type, LOOKUP_NORMAL, @@ -1286,13 +1286,13 @@ strip_typedefs_expr (tree t) case TREE_LIST: { - VEC(tree,gc) *vec = make_tree_vector (); + vec<tree, va_gc> *vec = make_tree_vector (); bool changed = false; tree it; for (it = t; it; it = TREE_CHAIN (it)) { tree val = strip_typedefs_expr (TREE_VALUE (t)); - VEC_safe_push (tree, gc, vec, val); + vec_safe_push (vec, val); if (val != TREE_VALUE (t)) changed = true; gcc_assert (TREE_PURPOSE (it) == NULL_TREE); @@ -1300,7 +1300,7 @@ strip_typedefs_expr (tree t) if (changed) { r = NULL_TREE; - FOR_EACH_VEC_ELT_REVERSE (tree, vec, i, it) + FOR_EACH_VEC_ELT_REVERSE (*vec, i, it) r = tree_cons (NULL_TREE, it, r); } else @@ -1312,13 +1312,13 @@ strip_typedefs_expr (tree t) case TREE_VEC: { bool changed = false; - VEC(tree,gc)* vec = make_tree_vector (); + vec<tree, va_gc> *vec = make_tree_vector (); n = TREE_VEC_LENGTH (t); - VEC_reserve (tree, gc, vec, n); + vec_safe_reserve (vec, n); for (i = 0; i < n; ++i) { tree op = strip_typedefs_expr (TREE_VEC_ELT (t, i)); - VEC_quick_push (tree, vec, op); + vec->quick_push (op); if (op != TREE_VEC_ELT (t, i)) changed = true; } @@ -1326,7 +1326,7 @@ strip_typedefs_expr (tree t) { r = copy_node (t); for (i = 0; i < n; ++i) - TREE_VEC_ELT (r, i) = VEC_index (tree, vec, i); + TREE_VEC_ELT (r, i) = (*vec)[i]; } else r = t; @@ -1337,13 +1337,13 @@ strip_typedefs_expr (tree t) case CONSTRUCTOR: { bool changed = false; - VEC(constructor_elt,gc) *vec - = VEC_copy (constructor_elt, gc, CONSTRUCTOR_ELTS (t)); + vec<constructor_elt, va_gc> *vec + = vec_safe_copy (CONSTRUCTOR_ELTS (t)); n = CONSTRUCTOR_NELTS (t); type = strip_typedefs (TREE_TYPE (t)); for (i = 0; i < n; ++i) { - constructor_elt *e = &VEC_index (constructor_elt, vec, i); + constructor_elt *e = &(*vec)[i]; tree op = strip_typedefs_expr (e->value); if (op != e->value) { @@ -1355,7 +1355,7 @@ strip_typedefs_expr (tree t) if (!changed && type == TREE_TYPE (t)) { - VEC_free (constructor_elt, gc, vec); + vec_free (vec); return t; } else @@ -1484,7 +1484,7 @@ copy_binfo (tree binfo, tree type, tree t, tree *igo_prev, int virt) { /* Push it onto the list after any virtual bases it contains will have been pushed. */ - VEC_quick_push (tree, CLASSTYPE_VBASECLASSES (t), new_binfo); + CLASSTYPE_VBASECLASSES (t)->quick_push (new_binfo); BINFO_VIRTUAL_P (new_binfo) = 1; BINFO_INHERITANCE_CHAIN (new_binfo) = TYPE_BINFO (t); } @@ -2184,9 +2184,9 @@ bot_replace (tree* t, int* /*walk_subtrees*/, void* data) /* In an NSDMI build_base_path defers building conversions to virtual bases, and we handle it here. */ tree basetype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (*t))); - VEC(tree,gc) *vbases = CLASSTYPE_VBASECLASSES (current_class_type); + vec<tree, va_gc> *vbases = CLASSTYPE_VBASECLASSES (current_class_type); int i; tree binfo; - FOR_EACH_VEC_ELT (tree, vbases, i, binfo) + FOR_EACH_VEC_SAFE_ELT (vbases, i, binfo) if (BINFO_TYPE (binfo) == basetype) break; *t = build_base_path (PLUS_EXPR, TREE_OPERAND (*t, 0), binfo, true, @@ -2327,7 +2327,7 @@ build_min_non_dep (enum tree_code code, tree non_dep, ...) that has been built. */ tree -build_min_non_dep_call_vec (tree non_dep, tree fn, VEC(tree,gc) *argvec) +build_min_non_dep_call_vec (tree non_dep, tree fn, vec<tree, va_gc> *argvec) { tree t = build_nt_call_vec (fn, argvec); if (REFERENCE_REF_P (non_dep)) @@ -3742,8 +3742,8 @@ stabilize_init (tree init, tree *initp) unsigned i; constructor_elt *ce; bool good = true; - VEC(constructor_elt,gc) *v = CONSTRUCTOR_ELTS (t); - for (i = 0; VEC_iterate (constructor_elt, v, i, ce); ++i) + vec<constructor_elt, va_gc> *v = CONSTRUCTOR_ELTS (t); + for (i = 0; vec_safe_iterate (v, i, &ce); ++i) { tree type = TREE_TYPE (ce->value); tree subinit; @@ -3827,7 +3827,7 @@ cp_fix_function_decl_p (tree decl) /* Don't fix same_body aliases. Although they don't have their own CFG, they share it with what they alias to. */ if (!node || !node->alias - || !VEC_length (ipa_ref_t, node->symbol.ref_list.references)) + || !vec_safe_length (node->symbol.ref_list.references)) return true; } diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 5d8c27d..1cbab61 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -59,7 +59,7 @@ static bool casts_away_constness (tree, tree, tsubst_flags_t); static void maybe_warn_about_returning_address_of_local (tree); static tree lookup_destructor (tree, tree, tree); static void warn_args_num (location_t, tree, bool); -static int convert_arguments (tree, VEC(tree,gc) **, tree, int, +static int convert_arguments (tree, vec<tree, va_gc> **, tree, int, tsubst_flags_t); /* Do `exp = require_complete_type (exp);' to make sure exp @@ -3270,10 +3270,10 @@ build_function_call (location_t /*loc*/, /* Used by the C-common bits. */ tree build_function_call_vec (location_t /*loc*/, - tree function, VEC(tree,gc) *params, - VEC(tree,gc) * /*origtypes*/) + tree function, vec<tree, va_gc> *params, + vec<tree, va_gc> * /*origtypes*/) { - VEC(tree,gc) *orig_params = params; + vec<tree, va_gc> *orig_params = params; tree ret = cp_build_function_call_vec (function, ¶ms, tf_warning_or_error); @@ -3290,12 +3290,12 @@ build_function_call_vec (location_t /*loc*/, tree cp_build_function_call (tree function, tree params, tsubst_flags_t complain) { - VEC(tree,gc) *vec; + vec<tree, va_gc> *vec; tree ret; vec = make_tree_vector (); for (; params != NULL_TREE; params = TREE_CHAIN (params)) - VEC_safe_push (tree, gc, vec, TREE_VALUE (params)); + vec_safe_push (vec, TREE_VALUE (params)); ret = cp_build_function_call_vec (function, &vec, complain); release_tree_vector (vec); return ret; @@ -3306,14 +3306,14 @@ cp_build_function_call (tree function, tree params, tsubst_flags_t complain) tree cp_build_function_call_nary (tree function, tsubst_flags_t complain, ...) { - VEC(tree,gc) *vec; + vec<tree, va_gc> *vec; va_list args; tree ret, t; vec = make_tree_vector (); va_start (args, complain); for (t = va_arg (args, tree); t != NULL_TREE; t = va_arg (args, tree)) - VEC_safe_push (tree, gc, vec, t); + vec_safe_push (vec, t); va_end (args); ret = cp_build_function_call_vec (function, &vec, complain); release_tree_vector (vec); @@ -3325,7 +3325,7 @@ cp_build_function_call_nary (tree function, tsubst_flags_t complain, ...) PARAMS. */ tree -cp_build_function_call_vec (tree function, VEC(tree,gc) **params, +cp_build_function_call_vec (tree function, vec<tree, va_gc> **params, tsubst_flags_t complain) { tree fntype, fndecl; @@ -3334,14 +3334,13 @@ cp_build_function_call_vec (tree function, VEC(tree,gc) **params, int nargs; tree *argarray; tree parm_types; - VEC(tree,gc) *allocated = NULL; + vec<tree, va_gc> *allocated = NULL; tree ret; /* For Objective-C, convert any calls via a cast to OBJC_TYPE_REF expressions, like those used for ObjC messenger dispatches. */ - if (params != NULL && !VEC_empty (tree, *params)) - function = objc_rewrite_function_call (function, - VEC_index (tree, *params, 0)); + if (params != NULL && !vec_safe_is_empty (*params)) + function = objc_rewrite_function_call (function, (**params)[0]); /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue. Strip such NOP_EXPRs, since FUNCTION is used in non-lvalue context. */ @@ -3421,7 +3420,7 @@ cp_build_function_call_vec (tree function, VEC(tree,gc) **params, if (nargs < 0) return error_mark_node; - argarray = VEC_address (tree, *params); + argarray = (*params)->address (); /* Check for errors in format strings and inappropriately null parameters. */ @@ -3499,7 +3498,7 @@ warn_args_num (location_t loc, tree fndecl, bool too_many_p) default arguments, if such were specified. Do so here. */ static int -convert_arguments (tree typelist, VEC(tree,gc) **values, tree fndecl, +convert_arguments (tree typelist, vec<tree, va_gc> **values, tree fndecl, int flags, tsubst_flags_t complain) { tree typetail; @@ -3509,11 +3508,11 @@ convert_arguments (tree typelist, VEC(tree,gc) **values, tree fndecl, flags |= LOOKUP_ONLYCONVERTING; for (i = 0, typetail = typelist; - i < VEC_length (tree, *values); + i < vec_safe_length (*values); i++) { tree type = typetail ? TREE_VALUE (typetail) : 0; - tree val = VEC_index (tree, *values, i); + tree val = (**values)[i]; if (val == error_mark_node || type == error_mark_node) return -1; @@ -3575,7 +3574,7 @@ convert_arguments (tree typelist, VEC(tree,gc) **values, tree fndecl, if (parmval == error_mark_node) return -1; - VEC_replace (tree, *values, i, parmval); + (**values)[i] = parmval; } else { @@ -3588,7 +3587,7 @@ convert_arguments (tree typelist, VEC(tree,gc) **values, tree fndecl, else val = convert_arg_to_ellipsis (val, complain); - VEC_replace (tree, *values, i, val); + (**values)[i] = val; } if (typetail) @@ -3617,7 +3616,7 @@ convert_arguments (tree typelist, VEC(tree,gc) **values, tree fndecl, if (parmval == error_mark_node) return -1; - VEC_safe_push (tree, gc, *values, parmval); + vec_safe_push (*values, parmval); typetail = TREE_CHAIN (typetail); /* ends with `...'. */ if (typetail == NULL_TREE) @@ -5880,13 +5879,13 @@ build_x_compound_expr_from_list (tree list, expr_list_kind exp, /* Like build_x_compound_expr_from_list, but using a VEC. */ tree -build_x_compound_expr_from_vec (VEC(tree,gc) *vec, const char *msg, +build_x_compound_expr_from_vec (vec<tree, va_gc> *vec, const char *msg, tsubst_flags_t complain) { - if (VEC_empty (tree, vec)) + if (vec_safe_is_empty (vec)) return NULL_TREE; - else if (VEC_length (tree, vec) == 1) - return VEC_index (tree, vec, 0); + else if (vec->length () == 1) + return (*vec)[0]; else { tree expr; @@ -5903,8 +5902,8 @@ build_x_compound_expr_from_vec (VEC(tree,gc) *vec, const char *msg, return error_mark_node; } - expr = VEC_index (tree, vec, 0); - for (ix = 1; VEC_iterate (tree, vec, ix, t); ++ix) + expr = (*vec)[0]; + for (ix = 1; vec->iterate (ix, &t); ++ix) expr = build_x_compound_expr (EXPR_LOCATION (t), expr, t, complain); @@ -7090,7 +7089,7 @@ cp_build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs, /* Do the default thing. */; else { - VEC(tree,gc) *rhs_vec = make_tree_vector_single (rhs); + vec<tree, va_gc> *rhs_vec = make_tree_vector_single (rhs); result = build_special_member_call (lhs, complete_ctor_identifier, &rhs_vec, lhstype, LOOKUP_NORMAL, complain); @@ -7457,7 +7456,7 @@ build_ptrmemfunc1 (tree type, tree delta, tree pfn) tree u = NULL_TREE; tree delta_field; tree pfn_field; - VEC(constructor_elt, gc) *v; + vec<constructor_elt, va_gc> *v; /* Pull the FIELD_DECLs out of the type. */ pfn_field = TYPE_FIELDS (type); @@ -7470,7 +7469,7 @@ build_ptrmemfunc1 (tree type, tree delta, tree pfn) pfn = fold_convert (TREE_TYPE (pfn_field), pfn); /* Finish creating the initializer. */ - v = VEC_alloc(constructor_elt, gc, 2); + vec_alloc (v, 2); CONSTRUCTOR_APPEND_ELT(v, pfn_field, pfn); CONSTRUCTOR_APPEND_ELT(v, delta_field, delta); u = build_constructor (type, v); diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 3478886..c7262f4 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -253,7 +253,7 @@ complete_type_check_abstract (tree type) int abstract_virtuals_error_sfinae (tree decl, tree type, tsubst_flags_t complain) { - VEC(tree,gc) *pure; + vec<tree, va_gc> *pure; /* This function applies only to classes. Any other entity can never be abstract. */ @@ -331,7 +331,7 @@ abstract_virtuals_error_sfinae (tree decl, tree type, tsubst_flags_t complain) error ("cannot allocate an object of abstract type %qT", type); /* Only go through this once. */ - if (VEC_length (tree, pure)) + if (pure->length ()) { unsigned ix; tree fn; @@ -340,7 +340,7 @@ abstract_virtuals_error_sfinae (tree decl, tree type, tsubst_flags_t complain) " because the following virtual functions are pure within %qT:", type); - FOR_EACH_VEC_ELT (tree, pure, ix, fn) + FOR_EACH_VEC_ELT (*pure, ix, fn) if (! DECL_CLONED_FUNCTION_P (fn) || DECL_COMPLETE_DESTRUCTOR_P (fn)) inform (input_location, "\t%+#D", fn); @@ -348,7 +348,7 @@ abstract_virtuals_error_sfinae (tree decl, tree type, tsubst_flags_t complain) /* Now truncate the vector. This leaves it non-null, so we know there are pure virtuals, but empty so we don't list them out again. */ - VEC_truncate (tree, pure, 0); + pure->truncate (0); } else inform (DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (type)), @@ -566,8 +566,7 @@ split_nonconstant_init_1 (tree dest, tree init) split_non_constant_init into process_init_constructor_array, that is separating constants from non-constants while building the vector. */ - VEC_ordered_remove (constructor_elt, CONSTRUCTOR_ELTS (init), - idx); + CONSTRUCTOR_ELTS (init)->ordered_remove (idx); --idx; if (array_type_p) @@ -661,7 +660,7 @@ split_nonconstant_init (tree dest, tree init) for static variable. In that case, caller must emit the code. */ tree -store_init_value (tree decl, tree init, VEC(tree,gc)** cleanups, int flags) +store_init_value (tree decl, tree init, vec<tree, va_gc>** cleanups, int flags) { tree value, type; @@ -1047,7 +1046,7 @@ process_init_constructor_array (tree type, tree init, int flags = 0; bool unbounded = false; constructor_elt *ce; - VEC(constructor_elt,gc) *v = CONSTRUCTOR_ELTS (init); + vec<constructor_elt, va_gc> *v = CONSTRUCTOR_ELTS (init); gcc_assert (TREE_CODE (type) == ARRAY_TYPE || TREE_CODE (type) == VECTOR_TYPE); @@ -1070,7 +1069,7 @@ process_init_constructor_array (tree type, tree init, len = TYPE_VECTOR_SUBPARTS (type); /* There must not be more initializers than needed. */ - if (!unbounded && VEC_length (constructor_elt, v) > len) + if (!unbounded && vec_safe_length (v) > len) { if (complain & tf_error) error ("too many initializers for %qT", type); @@ -1078,7 +1077,7 @@ process_init_constructor_array (tree type, tree init, return PICFLAG_ERRONEOUS; } - FOR_EACH_VEC_ELT (constructor_elt, v, i, ce) + FOR_EACH_VEC_SAFE_ELT (v, i, ce) { if (ce->index) { @@ -1142,7 +1141,7 @@ static int process_init_constructor_record (tree type, tree init, tsubst_flags_t complain) { - VEC(constructor_elt,gc) *v = NULL; + vec<constructor_elt, va_gc> *v = NULL; int flags = 0; tree field; unsigned HOST_WIDE_INT idx = 0; @@ -1176,10 +1175,9 @@ process_init_constructor_record (tree type, tree init, if (DECL_BIT_FIELD_TYPE (field)) type = DECL_BIT_FIELD_TYPE (field); - if (idx < VEC_length (constructor_elt, CONSTRUCTOR_ELTS (init))) + if (idx < vec_safe_length (CONSTRUCTOR_ELTS (init))) { - constructor_elt *ce = &VEC_index (constructor_elt, - CONSTRUCTOR_ELTS (init), idx); + constructor_elt *ce = &(*CONSTRUCTOR_ELTS (init))[idx]; if (ce->index) { /* We can have either a FIELD_DECL or an IDENTIFIER_NODE. The @@ -1269,7 +1267,7 @@ process_init_constructor_record (tree type, tree init, CONSTRUCTOR_APPEND_ELT (v, field, next); } - if (idx < VEC_length (constructor_elt, CONSTRUCTOR_ELTS (init))) + if (idx < vec_safe_length (CONSTRUCTOR_ELTS (init))) { if (complain & tf_error) error ("too many initializers for %qT", type); @@ -1293,19 +1291,19 @@ process_init_constructor_union (tree type, tree init, int len; /* If the initializer was empty, use default zero initialization. */ - if (VEC_empty (constructor_elt, CONSTRUCTOR_ELTS (init))) + if (vec_safe_is_empty (CONSTRUCTOR_ELTS (init))) return 0; - len = VEC_length (constructor_elt, CONSTRUCTOR_ELTS (init)); + len = CONSTRUCTOR_ELTS (init)->length (); if (len > 1) { if (!(complain & tf_error)) return PICFLAG_ERRONEOUS; error ("too many initializers for %qT", type); - VEC_block_remove (constructor_elt, CONSTRUCTOR_ELTS (init), 1, len-1); + CONSTRUCTOR_ELTS (init)->block_remove (1, len-1); } - ce = &VEC_index (constructor_elt, CONSTRUCTOR_ELTS (init), 0); + ce = &(*CONSTRUCTOR_ELTS (init))[0]; /* If this element specifies a field, initialize via that field. */ if (ce->index) @@ -1476,7 +1474,7 @@ build_x_arrow (location_t loc, tree expr, tsubst_flags_t complain) tree orig_expr = expr; tree type = TREE_TYPE (expr); tree last_rval = NULL_TREE; - VEC(tree,gc) *types_memoized = NULL; + vec<tree, va_gc> *types_memoized = NULL; if (type == error_mark_node) return error_mark_node; @@ -1511,7 +1509,7 @@ build_x_arrow (location_t loc, tree expr, tsubst_flags_t complain) return error_mark_node; } - VEC_safe_push (tree, gc, types_memoized, TREE_TYPE (expr)); + vec_safe_push (types_memoized, TREE_TYPE (expr)); last_rval = expr; } @@ -1665,7 +1663,7 @@ build_functional_cast (tree exp, tree parms, tsubst_flags_t complain) /* The type to which we are casting. */ tree type; - VEC(tree,gc) *parmvec; + vec<tree, va_gc> *parmvec; if (exp == error_mark_node || parms == error_mark_node) return error_mark_node; @@ -1762,7 +1760,7 @@ build_functional_cast (tree exp, tree parms, tsubst_flags_t complain) /* Call the constructor. */ parmvec = make_tree_vector (); for (; parms != NULL_TREE; parms = TREE_CHAIN (parms)) - VEC_safe_push (tree, gc, parmvec, TREE_VALUE (parms)); + vec_safe_push (parmvec, TREE_VALUE (parms)); exp = build_special_member_call (NULL_TREE, complete_ctor_identifier, &parmvec, type, LOOKUP_NORMAL, complain); release_tree_vector (parmvec); |