diff options
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/c-common.c | 245 | ||||
-rw-r--r-- | gcc/c-family/c-common.h | 32 | ||||
-rw-r--r-- | gcc/c-family/c-gimplify.c | 4 | ||||
-rw-r--r-- | gcc/c-family/c-pragma.c | 75 | ||||
-rw-r--r-- | gcc/c-family/c-pretty-print.c | 4 | ||||
-rw-r--r-- | gcc/c-family/c-pretty-print.h | 2 | ||||
-rw-r--r-- | gcc/c-family/c-semantics.c | 8 |
7 files changed, 173 insertions, 197 deletions
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 7828d210507..fac71901e0f 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -1839,7 +1839,7 @@ strict_aliasing_warning (tree otype, tree type, tree expr) void sizeof_pointer_memaccess_warning (location_t *sizeof_arg_loc, tree callee, - VEC(tree, gc) *params, tree *sizeof_arg, + vec<tree, va_gc> *params, tree *sizeof_arg, bool (*comp_types) (tree, tree)) { tree type, dest = NULL_TREE, src = NULL_TREE, tem; @@ -1849,7 +1849,7 @@ sizeof_pointer_memaccess_warning (location_t *sizeof_arg_loc, tree callee, if (TREE_CODE (callee) != FUNCTION_DECL || DECL_BUILT_IN_CLASS (callee) != BUILT_IN_NORMAL - || VEC_length (tree, params) <= 1) + || vec_safe_length (params) <= 1) return; switch (DECL_FUNCTION_CODE (callee)) @@ -1870,55 +1870,55 @@ sizeof_pointer_memaccess_warning (location_t *sizeof_arg_loc, tree callee, case BUILT_IN_MEMCPY_CHK: case BUILT_IN_MEMMOVE: case BUILT_IN_MEMMOVE_CHK: - if (VEC_length (tree, params) < 3) + if (params->length () < 3) return; - src = VEC_index (tree, params, 1); - dest = VEC_index (tree, params, 0); + src = (*params)[1]; + dest = (*params)[0]; idx = 2; break; case BUILT_IN_BCOPY: - if (VEC_length (tree, params) < 3) + if (params->length () < 3) return; - src = VEC_index (tree, params, 0); - dest = VEC_index (tree, params, 1); + src = (*params)[0]; + dest = (*params)[1]; idx = 2; break; case BUILT_IN_MEMCMP: case BUILT_IN_BCMP: - if (VEC_length (tree, params) < 3) + if (params->length () < 3) return; - src = VEC_index (tree, params, 1); - dest = VEC_index (tree, params, 0); + src = (*params)[1]; + dest = (*params)[0]; idx = 2; cmp = true; break; case BUILT_IN_MEMSET: case BUILT_IN_MEMSET_CHK: - if (VEC_length (tree, params) < 3) + if (params->length () < 3) return; - dest = VEC_index (tree, params, 0); + dest = (*params)[0]; idx = 2; break; case BUILT_IN_BZERO: - dest = VEC_index (tree, params, 0); + dest = (*params)[0]; idx = 1; break; case BUILT_IN_STRNDUP: - src = VEC_index (tree, params, 0); + src = (*params)[0]; strop = true; idx = 1; break; case BUILT_IN_MEMCHR: - if (VEC_length (tree, params) < 3) + if (params->length () < 3) return; - src = VEC_index (tree, params, 0); + src = (*params)[0]; idx = 2; break; case BUILT_IN_SNPRINTF: case BUILT_IN_SNPRINTF_CHK: case BUILT_IN_VSNPRINTF: case BUILT_IN_VSNPRINTF_CHK: - dest = VEC_index (tree, params, 0); + dest = (*params)[0]; idx = 1; strop = true; break; @@ -8729,9 +8729,7 @@ handle_target_attribute (tree *node, tree name, tree args, int flags, /* Arguments being collected for optimization. */ typedef const char *const_char_p; /* For DEF_VEC_P. */ -DEF_VEC_P(const_char_p); -DEF_VEC_ALLOC_P(const_char_p, gc); -static GTY(()) VEC(const_char_p, gc) *optimize_args; +static GTY(()) vec<const_char_p, va_gc> *optimize_args; /* Inner function to convert a TREE_LIST to argv string to parse the optimize @@ -8752,8 +8750,8 @@ parse_optimize_options (tree args, bool attr_p) /* Build up argv vector. Just in case the string is stored away, use garbage collected strings. */ - VEC_truncate (const_char_p, optimize_args, 0); - VEC_safe_push (const_char_p, gc, optimize_args, NULL); + vec_safe_truncate (optimize_args, 0); + vec_safe_push (optimize_args, (const char *) NULL); for (ap = args; ap != NULL_TREE; ap = TREE_CHAIN (ap)) { @@ -8763,7 +8761,7 @@ parse_optimize_options (tree args, bool attr_p) { char buffer[20]; sprintf (buffer, "-O%ld", (long) TREE_INT_CST_LOW (value)); - VEC_safe_push (const_char_p, gc, optimize_args, ggc_strdup (buffer)); + vec_safe_push (optimize_args, ggc_strdup (buffer)); } else if (TREE_CODE (value) == STRING_CST) @@ -8825,17 +8823,17 @@ parse_optimize_options (tree args, bool attr_p) memcpy (r, p, len2); r[len2] = '\0'; - VEC_safe_push (const_char_p, gc, optimize_args, q); + vec_safe_push (optimize_args, (const char *) q); } } } - opt_argc = VEC_length (const_char_p, optimize_args); + opt_argc = optimize_args->length (); opt_argv = (const char **) alloca (sizeof (char *) * (opt_argc + 1)); for (i = 1; i < opt_argc; i++) - opt_argv[i] = VEC_index (const_char_p, optimize_args, i); + opt_argv[i] = (*optimize_args)[i]; saved_flag_strict_aliasing = flag_strict_aliasing; @@ -8852,7 +8850,7 @@ parse_optimize_options (tree args, bool attr_p) /* Don't allow changing -fstrict-aliasing. */ flag_strict_aliasing = saved_flag_strict_aliasing; - VEC_truncate (const_char_p, optimize_args, 0); + optimize_args->truncate (0); return ret; } @@ -9736,9 +9734,9 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default) } else if (TREE_CODE (initial_value) == CONSTRUCTOR) { - VEC(constructor_elt,gc) *v = CONSTRUCTOR_ELTS (initial_value); + vec<constructor_elt, va_gc> *v = CONSTRUCTOR_ELTS (initial_value); - if (VEC_empty (constructor_elt, v)) + if (vec_safe_is_empty (v)) { if (pedantic) failure = 3; @@ -9751,15 +9749,12 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default) constructor_elt *ce; bool fold_p = false; - if (VEC_index (constructor_elt, v, 0).index) + if ((*v)[0].index) maxindex = fold_convert_loc (input_location, sizetype, - VEC_index (constructor_elt, - v, 0).index); + (*v)[0].index); curindex = maxindex; - for (cnt = 1; - VEC_iterate (constructor_elt, v, cnt, ce); - cnt++) + for (cnt = 1; vec_safe_iterate (v, cnt, &ce); cnt++) { bool curfold_p = false; if (ce->index) @@ -9879,18 +9874,18 @@ builtin_type_for_size (int size, bool unsignedp) Returns 0 if an error is encountered. */ static int -sync_resolve_size (tree function, VEC(tree,gc) *params) +sync_resolve_size (tree function, vec<tree, va_gc> *params) { tree type; int size; - if (VEC_empty (tree, params)) + if (!params) { error ("too few arguments to function %qE", function); return 0; } - type = TREE_TYPE (VEC_index (tree, params, 0)); + type = TREE_TYPE ((*params)[0]); if (TREE_CODE (type) != POINTER_TYPE) goto incompatible; @@ -9914,7 +9909,7 @@ sync_resolve_size (tree function, VEC(tree,gc) *params) static bool sync_resolve_params (location_t loc, tree orig_function, tree function, - VEC(tree, gc) *params, bool orig_format) + vec<tree, va_gc> *params, bool orig_format) { function_args_iterator iter; tree ptype; @@ -9925,7 +9920,7 @@ sync_resolve_params (location_t loc, tree orig_function, tree function, as the pointer parameter, so we shouldn't get any complaints from the call to check_function_arguments what ever type the user used. */ function_args_iter_next (&iter); - ptype = TREE_TYPE (TREE_TYPE (VEC_index (tree, params, 0))); + ptype = TREE_TYPE (TREE_TYPE ((*params)[0])); /* For the rest of the values, we need to cast these to FTYPE, so that we don't get warnings for passing pointer types, etc. */ @@ -9940,7 +9935,7 @@ sync_resolve_params (location_t loc, tree orig_function, tree function, break; ++parmnum; - if (VEC_length (tree, params) <= parmnum) + if (params->length () <= parmnum) { error_at (loc, "too few arguments to function %qE", orig_function); return false; @@ -9956,17 +9951,17 @@ sync_resolve_params (location_t loc, tree orig_function, tree function, /* Ideally for the first conversion we'd use convert_for_assignment so that we get warnings for anything that doesn't match the pointer type. This isn't portable across the C and C++ front ends atm. */ - val = VEC_index (tree, params, parmnum); + val = (*params)[parmnum]; val = convert (ptype, val); val = convert (arg_type, val); - VEC_replace (tree, params, parmnum, val); + (*params)[parmnum] = val; } function_args_iter_next (&iter); } /* __atomic routines are not variadic. */ - if (!orig_format && VEC_length (tree, params) != parmnum + 1) + if (!orig_format && params->length () != parmnum + 1) { error_at (loc, "too many arguments to function %qE", orig_function); return false; @@ -9976,7 +9971,7 @@ sync_resolve_params (location_t loc, tree orig_function, tree function, being "an optional list of variables protected by the memory barrier". No clue what that's supposed to mean, precisely, but we consider all call-clobbered variables to be protected so we're safe. */ - VEC_truncate (tree, params, parmnum + 1); + params->truncate (parmnum + 1); return true; } @@ -10004,7 +9999,8 @@ sync_resolve_return (tree first_param, tree result, bool orig_format) 0 is returned if the parameters are invalid. */ static int -get_atomic_generic_size (location_t loc, tree function, VEC(tree,gc) *params) +get_atomic_generic_size (location_t loc, tree function, + vec<tree, va_gc> *params) { unsigned int n_param; unsigned int n_model; @@ -10032,14 +10028,14 @@ get_atomic_generic_size (location_t loc, tree function, VEC(tree,gc) *params) gcc_unreachable (); } - if (VEC_length (tree, params) != n_param) + if (vec_safe_length (params) != n_param) { error_at (loc, "incorrect number of arguments to function %qE", function); return 0; } /* Get type of first parameter, and determine its size. */ - type_0 = TREE_TYPE (VEC_index (tree, params, 0)); + type_0 = TREE_TYPE ((*params)[0]); if (TREE_CODE (type_0) != POINTER_TYPE || VOID_TYPE_P (TREE_TYPE (type_0))) { error_at (loc, "argument 1 of %qE must be a non-void pointer type", @@ -10071,7 +10067,7 @@ get_atomic_generic_size (location_t loc, tree function, VEC(tree,gc) *params) for (x = 0; x < n_param - n_model; x++) { int size; - tree type = TREE_TYPE (VEC_index (tree, params, x)); + tree type = TREE_TYPE ((*params)[x]); /* __atomic_compare_exchange has a bool in the 4th postion, skip it. */ if (n_param == 6 && x == 3) continue; @@ -10093,7 +10089,7 @@ get_atomic_generic_size (location_t loc, tree function, VEC(tree,gc) *params) /* Check memory model parameters for validity. */ for (x = n_param - n_model ; x < n_param; x++) { - tree p = VEC_index (tree, params, x); + tree p = (*params)[x]; if (TREE_CODE (p) == INTEGER_CST) { int i = tree_low_cst (p, 1); @@ -10126,30 +10122,30 @@ get_atomic_generic_size (location_t loc, tree function, VEC(tree,gc) *params) static tree add_atomic_size_parameter (unsigned n, location_t loc, tree function, - VEC(tree,gc) *params) + vec<tree, va_gc> *params) { tree size_node; /* Insert a SIZE_T parameter as the first param. If there isn't enough space, allocate a new vector and recursively re-build with that. */ - if (!VEC_space (tree, params, 1)) + if (!params->space (1)) { unsigned int z, len; - VEC(tree,gc) *vec; + vec<tree, va_gc> *v; tree f; - len = VEC_length (tree, params); - vec = VEC_alloc (tree, gc, len + 1); + len = params->length (); + vec_alloc (v, len + 1); for (z = 0; z < len; z++) - VEC_quick_push (tree, vec, VEC_index (tree, params, z)); - f = build_function_call_vec (loc, function, vec, NULL); - VEC_free (tree, gc, vec); + v->quick_push ((*params)[z]); + f = build_function_call_vec (loc, function, v, NULL); + vec_free (v); return f; } /* Add the size parameter and leave as a function call for processing. */ size_node = build_int_cst (size_type_node, n); - VEC_quick_insert (tree, params, 0, size_node); + params->quick_insert (0, size_node); return NULL_TREE; } @@ -10165,7 +10161,7 @@ add_atomic_size_parameter (unsigned n, location_t loc, tree function, NEW_RETURN is set to the the return value the result is copied into. */ static bool resolve_overloaded_atomic_exchange (location_t loc, tree function, - VEC(tree,gc) *params, tree *new_return) + vec<tree, va_gc> *params, tree *new_return) { tree p0, p1, p2, p3; tree I_type, I_type_ptr; @@ -10190,10 +10186,10 @@ resolve_overloaded_atomic_exchange (location_t loc, tree function, into *return = (T) (fn (In* mem, (In) *desired, model)) */ - p0 = VEC_index (tree, params, 0); - p1 = VEC_index (tree, params, 1); - p2 = VEC_index (tree, params, 2); - p3 = VEC_index (tree, params, 3); + p0 = (*params)[0]; + p1 = (*params)[1]; + p2 = (*params)[2]; + p3 = (*params)[3]; /* Create pointer to appropriate size. */ I_type = builtin_type_for_size (BITS_PER_UNIT * n, 1); @@ -10201,15 +10197,15 @@ resolve_overloaded_atomic_exchange (location_t loc, tree function, /* Convert object pointer to required type. */ p0 = build1 (VIEW_CONVERT_EXPR, I_type_ptr, p0); - VEC_replace (tree, params, 0, p0); + (*params)[0] = p0; /* Convert new value to required type, and dereference it. */ p1 = build_indirect_ref (loc, p1, RO_UNARY_STAR); p1 = build1 (VIEW_CONVERT_EXPR, I_type, p1); - VEC_replace (tree, params, 1, p1); + (*params)[1] = p1; /* Move memory model to the 3rd position, and end param list. */ - VEC_replace (tree, params, 2, p3); - VEC_truncate (tree, params, 3); + (*params)[2] = p3; + params->truncate (3); /* Convert return pointer and dereference it for later assignment. */ *new_return = build_indirect_ref (loc, p2, RO_UNARY_STAR); @@ -10229,7 +10225,7 @@ resolve_overloaded_atomic_exchange (location_t loc, tree function, static bool resolve_overloaded_atomic_compare_exchange (location_t loc, tree function, - VEC(tree,gc) *params, + vec<tree, va_gc> *params, tree *new_return) { tree p0, p1, p2; @@ -10253,9 +10249,9 @@ resolve_overloaded_atomic_compare_exchange (location_t loc, tree function, there is no danger this will be done twice. */ if (n > 0) { - VEC_replace (tree, params, 3, VEC_index (tree, params, 4)); - VEC_replace (tree, params, 4, VEC_index (tree, params, 5)); - VEC_truncate (tree, params, 5); + (*params)[3] = (*params)[4]; + (*params)[4] = (*params)[5]; + params->truncate (5); } *new_return = add_atomic_size_parameter (n, loc, function, params); return true; @@ -10266,9 +10262,9 @@ resolve_overloaded_atomic_compare_exchange (location_t loc, tree function, into bool fn ((In *)mem, (In *)expected, (In) *desired, weak, succ, fail) */ - p0 = VEC_index (tree, params, 0); - p1 = VEC_index (tree, params, 1); - p2 = VEC_index (tree, params, 2); + p0 = (*params)[0]; + p1 = (*params)[1]; + p2 = (*params)[2]; /* Create pointer to appropriate size. */ I_type = builtin_type_for_size (BITS_PER_UNIT * n, 1); @@ -10276,16 +10272,16 @@ resolve_overloaded_atomic_compare_exchange (location_t loc, tree function, /* Convert object pointer to required type. */ p0 = build1 (VIEW_CONVERT_EXPR, I_type_ptr, p0); - VEC_replace (tree, params, 0, p0); + (*params)[0] = p0; /* Convert expected pointer to required type. */ p1 = build1 (VIEW_CONVERT_EXPR, I_type_ptr, p1); - VEC_replace (tree, params, 1, p1); + (*params)[1] = p1; /* Convert desired value to required type, and dereference it. */ p2 = build_indirect_ref (loc, p2, RO_UNARY_STAR); p2 = build1 (VIEW_CONVERT_EXPR, I_type, p2); - VEC_replace (tree, params, 2, p2); + (*params)[2] = p2; /* The rest of the parameters are fine. NULL means no special return value processing.*/ @@ -10306,7 +10302,7 @@ resolve_overloaded_atomic_compare_exchange (location_t loc, tree function, static bool resolve_overloaded_atomic_load (location_t loc, tree function, - VEC(tree,gc) *params, tree *new_return) + vec<tree, va_gc> *params, tree *new_return) { tree p0, p1, p2; tree I_type, I_type_ptr; @@ -10331,9 +10327,9 @@ resolve_overloaded_atomic_load (location_t loc, tree function, into *return = (T) (fn ((In *) mem, model)) */ - p0 = VEC_index (tree, params, 0); - p1 = VEC_index (tree, params, 1); - p2 = VEC_index (tree, params, 2); + p0 = (*params)[0]; + p1 = (*params)[1]; + p2 = (*params)[2]; /* Create pointer to appropriate size. */ I_type = builtin_type_for_size (BITS_PER_UNIT * n, 1); @@ -10341,11 +10337,11 @@ resolve_overloaded_atomic_load (location_t loc, tree function, /* Convert object pointer to required type. */ p0 = build1 (VIEW_CONVERT_EXPR, I_type_ptr, p0); - VEC_replace (tree, params, 0, p0); + (*params)[0] = p0; /* Move memory model to the 2nd position, and end param list. */ - VEC_replace (tree, params, 1, p2); - VEC_truncate (tree, params, 2); + (*params)[1] = p2; + params->truncate (2); /* Convert return pointer and dereference it for later assignment. */ *new_return = build_indirect_ref (loc, p1, RO_UNARY_STAR); @@ -10366,7 +10362,7 @@ resolve_overloaded_atomic_load (location_t loc, tree function, static bool resolve_overloaded_atomic_store (location_t loc, tree function, - VEC(tree,gc) *params, tree *new_return) + vec<tree, va_gc> *params, tree *new_return) { tree p0, p1; tree I_type, I_type_ptr; @@ -10391,8 +10387,8 @@ resolve_overloaded_atomic_store (location_t loc, tree function, into fn ((In *) mem, (In) *value, model) */ - p0 = VEC_index (tree, params, 0); - p1 = VEC_index (tree, params, 1); + p0 = (*params)[0]; + p1 = (*params)[1]; /* Create pointer to appropriate size. */ I_type = builtin_type_for_size (BITS_PER_UNIT * n, 1); @@ -10400,12 +10396,12 @@ resolve_overloaded_atomic_store (location_t loc, tree function, /* Convert object pointer to required type. */ p0 = build1 (VIEW_CONVERT_EXPR, I_type_ptr, p0); - VEC_replace (tree, params, 0, p0); + (*params)[0] = p0; /* Convert new value to required type, and dereference it. */ p1 = build_indirect_ref (loc, p1, RO_UNARY_STAR); p1 = build1 (VIEW_CONVERT_EXPR, I_type, p1); - VEC_replace (tree, params, 1, p1); + (*params)[1] = p1; /* The memory model is in the right spot already. Return is void. */ *new_return = NULL_TREE; @@ -10426,7 +10422,8 @@ resolve_overloaded_atomic_store (location_t loc, tree function, continue. */ tree -resolve_overloaded_builtin (location_t loc, tree function, VEC(tree,gc) *params) +resolve_overloaded_builtin (location_t loc, tree function, + vec<tree, va_gc> *params) { enum built_in_function orig_code = DECL_FUNCTION_CODE (function); bool orig_format = true; @@ -10550,7 +10547,7 @@ resolve_overloaded_builtin (location_t loc, tree function, VEC(tree,gc) *params) orig_format)) return error_mark_node; - first_param = VEC_index (tree, params, 0); + first_param = (*params)[0]; result = build_function_call_vec (loc, new_function, params, NULL); if (result == error_mark_node) return result; @@ -11097,9 +11094,9 @@ record_types_used_by_current_var_decl (tree decl) { gcc_assert (decl && DECL_P (decl) && TREE_STATIC (decl)); - while (!VEC_empty (tree, types_used_by_cur_var_decl)) + while (types_used_by_cur_var_decl && !types_used_by_cur_var_decl->is_empty ()) { - tree type = VEC_pop (tree, types_used_by_cur_var_decl); + tree type = types_used_by_cur_var_decl->pop (); types_used_by_var_decl_insert (type, decl); } } @@ -11121,7 +11118,7 @@ record_locally_defined_typedef (tree decl) return; l = (struct c_language_function *) cfun->language; - VEC_safe_push (tree, gc, l->local_typedefs, decl); + vec_safe_push (l->local_typedefs, decl); } /* If T is a TYPE_DECL declared locally, mark it as used. */ @@ -11159,7 +11156,7 @@ maybe_warn_unused_local_typedefs (void) if (warn_unused_local_typedefs && errorcount == unused_local_typedefs_warn_count) { - FOR_EACH_VEC_ELT (tree, l->local_typedefs, i, decl) + FOR_EACH_VEC_SAFE_ELT (l->local_typedefs, i, decl) if (!TREE_USED (decl)) warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wunused_local_typedefs, @@ -11167,86 +11164,82 @@ maybe_warn_unused_local_typedefs (void) unused_local_typedefs_warn_count = errorcount; } - if (l->local_typedefs) - { - VEC_free (tree, gc, l->local_typedefs); - l->local_typedefs = NULL; - } + vec_free (l->local_typedefs); } /* The C and C++ parsers both use vectors to hold function arguments. For efficiency, we keep a cache of unused vectors. This is the cache. */ -typedef VEC(tree,gc)* tree_gc_vec; -DEF_VEC_P(tree_gc_vec); -DEF_VEC_ALLOC_P(tree_gc_vec,gc); -static GTY((deletable)) VEC(tree_gc_vec,gc) *tree_vector_cache; +typedef vec<tree, va_gc> *tree_gc_vec; +static GTY((deletable)) vec<tree_gc_vec, va_gc> *tree_vector_cache; /* Return a new vector from the cache. If the cache is empty, allocate a new vector. These vectors are GC'ed, so it is OK if the pointer is not released.. */ -VEC(tree,gc) * +vec<tree, va_gc> * make_tree_vector (void) { - if (!VEC_empty (tree_gc_vec, tree_vector_cache)) - return VEC_pop (tree_gc_vec, tree_vector_cache); + if (tree_vector_cache && !tree_vector_cache->is_empty ()) + return tree_vector_cache->pop (); else { - /* Passing 0 to VEC_alloc returns NULL, and our callers require + /* Passing 0 to vec::alloc returns NULL, and our callers require that we always return a non-NULL value. The vector code uses 4 when growing a NULL vector, so we do too. */ - return VEC_alloc (tree, gc, 4); + vec<tree, va_gc> *v; + vec_alloc (v, 4); + return v; } } /* Release a vector of trees back to the cache. */ void -release_tree_vector (VEC(tree,gc) *vec) +release_tree_vector (vec<tree, va_gc> *vec) { if (vec != NULL) { - VEC_truncate (tree, vec, 0); - VEC_safe_push (tree_gc_vec, gc, tree_vector_cache, vec); + vec->truncate (0); + vec_safe_push (tree_vector_cache, vec); } } /* Get a new tree vector holding a single tree. */ -VEC(tree,gc) * +vec<tree, va_gc> * make_tree_vector_single (tree t) { - VEC(tree,gc) *ret = make_tree_vector (); - VEC_quick_push (tree, ret, t); + vec<tree, va_gc> *ret = make_tree_vector (); + ret->quick_push (t); return ret; } /* Get a new tree vector of the TREE_VALUEs of a TREE_LIST chain. */ -VEC(tree,gc) * +vec<tree, va_gc> * make_tree_vector_from_list (tree list) { - VEC(tree,gc) *ret = make_tree_vector (); + vec<tree, va_gc> *ret = make_tree_vector (); for (; list; list = TREE_CHAIN (list)) - VEC_safe_push (tree, gc, ret, TREE_VALUE (list)); + vec_safe_push (ret, TREE_VALUE (list)); return ret; } /* Get a new tree vector which is a copy of an existing one. */ -VEC(tree,gc) * -make_tree_vector_copy (const VEC(tree,gc) *orig) +vec<tree, va_gc> * +make_tree_vector_copy (const vec<tree, va_gc> *orig) { - VEC(tree,gc) *ret; + vec<tree, va_gc> *ret; unsigned int ix; tree t; ret = make_tree_vector (); - VEC_reserve (tree, gc, ret, VEC_length (tree, orig)); - FOR_EACH_VEC_ELT (tree, orig, ix, t) - VEC_quick_push (tree, ret, t); + vec_safe_reserve (ret, vec_safe_length (orig)); + FOR_EACH_VEC_SAFE_ELT (orig, ix, t) + ret->quick_push (t); return ret; } diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 5c545f2950f..afd8f07e72f 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -486,7 +486,7 @@ typedef enum ref_operator { struct GTY(()) stmt_tree_s { /* A stack of statement lists being collected. */ - VEC(tree,gc) *x_cur_stmt_list; + vec<tree, va_gc> *x_cur_stmt_list; /* In C++, Nonzero if we should treat statements as full expressions. In particular, this variable is non-zero if at the @@ -512,20 +512,16 @@ struct GTY(()) c_language_function { /* Vector of locally defined typedefs, for -Wunused-local-typedefs. */ - VEC(tree,gc) *local_typedefs; + vec<tree, va_gc> *local_typedefs; }; #define stmt_list_stack (current_stmt_tree ()->x_cur_stmt_list) /* When building a statement-tree, this is the current statement list - being collected. We define it in this convoluted way, rather than - using VEC_last, because it must be an lvalue. */ + being collected. */ +#define cur_stmt_list (stmt_list_stack->last ()) -#define cur_stmt_list \ - (*(VEC_address (tree, stmt_list_stack) \ - + VEC_length (tree, stmt_list_stack) - 1)) - -#define building_stmt_list_p() (!VEC_empty (tree, stmt_list_stack)) +#define building_stmt_list_p() (stmt_list_stack && !stmt_list_stack->is_empty()) /* Language-specific hooks. */ @@ -759,7 +755,7 @@ extern void constant_expression_warning (tree); extern void constant_expression_error (tree); extern bool strict_aliasing_warning (tree, tree, tree); extern void sizeof_pointer_memaccess_warning (location_t *, tree, - VEC(tree, gc) *, tree *, + vec<tree, va_gc> *, tree *, bool (*) (tree, tree)); extern void warnings_for_convert_and_check (tree, tree, tree); extern tree convert_and_check (tree, tree); @@ -899,10 +895,10 @@ extern void c_do_switch_warnings (splay_tree, location_t, tree, tree); extern tree build_function_call (location_t, tree, tree); -extern tree build_function_call_vec (location_t, tree, - VEC(tree,gc) *, VEC(tree,gc) *); +extern tree build_function_call_vec (location_t, tree, vec<tree, va_gc> *, + vec<tree, va_gc> *); -extern tree resolve_overloaded_builtin (location_t, tree, VEC(tree,gc) *); +extern tree resolve_overloaded_builtin (location_t, tree, vec<tree, va_gc> *); extern tree finish_label_address_expr (tree, location_t); @@ -997,11 +993,11 @@ extern void set_underlying_type (tree); extern void record_locally_defined_typedef (tree); extern void maybe_record_typedef_use (tree); extern void maybe_warn_unused_local_typedefs (void); -extern VEC(tree,gc) *make_tree_vector (void); -extern void release_tree_vector (VEC(tree,gc) *); -extern VEC(tree,gc) *make_tree_vector_single (tree); -extern VEC(tree,gc) *make_tree_vector_from_list (tree); -extern VEC(tree,gc) *make_tree_vector_copy (const VEC(tree,gc) *); +extern vec<tree, va_gc> *make_tree_vector (void); +extern void release_tree_vector (vec<tree, va_gc> *); +extern vec<tree, va_gc> *make_tree_vector_single (tree); +extern vec<tree, va_gc> *make_tree_vector_from_list (tree); +extern vec<tree, va_gc> *make_tree_vector_copy (const vec<tree, va_gc> *); /* In c-gimplify.c */ extern void c_genericize (tree); diff --git a/gcc/c-family/c-gimplify.c b/gcc/c-family/c-gimplify.c index 821c5d5d1ff..27814e1a1fb 100644 --- a/gcc/c-family/c-gimplify.c +++ b/gcc/c-family/c-gimplify.c @@ -108,9 +108,9 @@ add_block_to_enclosing (tree block) unsigned i; tree enclosing; gimple bind; - VEC(gimple, heap) *stack = gimple_bind_expr_stack (); + vec<gimple> stack = gimple_bind_expr_stack (); - FOR_EACH_VEC_ELT (gimple, stack, i, bind) + FOR_EACH_VEC_ELT (stack, i, bind) if (gimple_bind_block (bind)) break; diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c index 70d8748ece9..f04cc6f13f9 100644 --- a/gcc/c-family/c-pragma.c +++ b/gcc/c-family/c-pragma.c @@ -33,7 +33,6 @@ along with GCC; see the file COPYING3. If not see #include "tm_p.h" /* For REGISTER_TARGET_PRAGMAS (why is this not a target hook?). */ #include "vec.h" -#include "vecprim.h" #include "target.h" #include "diagnostic.h" #include "opts.h" @@ -241,10 +240,8 @@ typedef struct GTY(()) pending_weak_d tree value; } pending_weak; -DEF_VEC_O(pending_weak); -DEF_VEC_ALLOC_O(pending_weak,gc); -static GTY(()) VEC(pending_weak,gc) *pending_weaks; +static GTY(()) vec<pending_weak, va_gc> *pending_weaks; static void apply_pragma_weak (tree, tree); static void handle_pragma_weak (cpp_reader *); @@ -294,11 +291,11 @@ maybe_apply_pragma_weak (tree decl) id = DECL_ASSEMBLER_NAME (decl); - FOR_EACH_VEC_ELT (pending_weak, pending_weaks, i, pe) + FOR_EACH_VEC_ELT (*pending_weaks, i, pe) if (id == pe->name) { apply_pragma_weak (decl, pe->value); - VEC_unordered_remove (pending_weak, pending_weaks, i); + pending_weaks->unordered_remove (i); break; } } @@ -313,7 +310,10 @@ maybe_apply_pending_pragma_weaks (void) pending_weak *pe; symtab_node target; - FOR_EACH_VEC_ELT (pending_weak, pending_weaks, i, pe) + if (!pending_weaks) + return; + + FOR_EACH_VEC_ELT (*pending_weaks, i, pe) { alias_id = pe->name; id = pe->value; @@ -373,7 +373,7 @@ handle_pragma_weak (cpp_reader * ARG_UNUSED (dummy)) else { pending_weak pe = {name, value}; - VEC_safe_push (pending_weak, gc, pending_weaks, pe); + vec_safe_push (pending_weaks, pe); } } @@ -414,10 +414,8 @@ typedef struct GTY(()) pending_redefinition_d { tree newname; } pending_redefinition; -DEF_VEC_O(pending_redefinition); -DEF_VEC_ALLOC_O(pending_redefinition,gc); -static GTY(()) VEC(pending_redefinition,gc) *pending_redefine_extname; +static GTY(()) vec<pending_redefinition, va_gc> *pending_redefine_extname; static void handle_pragma_redefine_extname (cpp_reader *); @@ -488,7 +486,7 @@ add_to_renaming_pragma_list (tree oldname, tree newname) unsigned ix; pending_redefinition *p; - FOR_EACH_VEC_ELT (pending_redefinition, pending_redefine_extname, ix, p) + FOR_EACH_VEC_SAFE_ELT (pending_redefine_extname, ix, p) if (oldname == p->oldname) { if (p->newname != newname) @@ -498,7 +496,7 @@ add_to_renaming_pragma_list (tree oldname, tree newname) } pending_redefinition e = {oldname, newname}; - VEC_safe_push (pending_redefinition, gc, pending_redefine_extname, e); + vec_safe_push (pending_redefine_extname, e); } /* The current prefix set by #pragma extern_prefix. */ @@ -532,7 +530,7 @@ maybe_apply_renaming_pragma (tree decl, tree asmname) "conflict with previous rename"); /* Take any pending redefine_extname off the list. */ - FOR_EACH_VEC_ELT (pending_redefinition, pending_redefine_extname, ix, p) + FOR_EACH_VEC_SAFE_ELT (pending_redefine_extname, ix, p) if (DECL_NAME (decl) == p->oldname) { /* Only warn if there is a conflict. */ @@ -540,20 +538,18 @@ maybe_apply_renaming_pragma (tree decl, tree asmname) warning (OPT_Wpragmas, "#pragma redefine_extname ignored due to " "conflict with previous rename"); - VEC_unordered_remove (pending_redefinition, - pending_redefine_extname, ix); + pending_redefine_extname->unordered_remove (ix); break; } return 0; } /* Find out if we have a pending #pragma redefine_extname. */ - FOR_EACH_VEC_ELT (pending_redefinition, pending_redefine_extname, ix, p) + FOR_EACH_VEC_SAFE_ELT (pending_redefine_extname, ix, p) if (DECL_NAME (decl) == p->oldname) { tree newname = p->newname; - VEC_unordered_remove (pending_redefinition, - pending_redefine_extname, ix); + pending_redefine_extname->unordered_remove (ix); /* If we already have an asmname, #pragma redefine_extname is ignored (with a warning if it conflicts). */ @@ -600,7 +596,7 @@ maybe_apply_renaming_pragma (tree decl, tree asmname) static void handle_pragma_visibility (cpp_reader *); -static VEC (int, heap) *visstack; +static vec<int> visstack; /* Push the visibility indicated by STR onto the top of the #pragma visibility stack. KIND is 0 for #pragma GCC visibility, 1 for @@ -612,8 +608,7 @@ static VEC (int, heap) *visstack; void push_visibility (const char *str, int kind) { - VEC_safe_push (int, heap, visstack, - ((int) default_visibility) | (kind << 8)); + visstack.safe_push (((int) default_visibility) | (kind << 8)); if (!strcmp (str, "default")) default_visibility = VISIBILITY_DEFAULT; else if (!strcmp (str, "internal")) @@ -633,14 +628,14 @@ push_visibility (const char *str, int kind) bool pop_visibility (int kind) { - if (!VEC_length (int, visstack)) + if (!visstack.length ()) return false; - if ((VEC_last (int, visstack) >> 8) != kind) + if ((visstack.last () >> 8) != kind) return false; default_visibility - = (enum symbol_visibility) (VEC_pop (int, visstack) & 0xff); + = (enum symbol_visibility) (visstack.pop () & 0xff); visibility_options.inpragma - = VEC_length (int, visstack) != 0; + = visstack.length () != 0; return true; } @@ -1152,10 +1147,8 @@ handle_pragma_float_const_decimal64 (cpp_reader *ARG_UNUSED (dummy)) } /* A vector of registered pragma callbacks, which is never freed. */ -DEF_VEC_O (internal_pragma_handler); -DEF_VEC_ALLOC_O (internal_pragma_handler, heap); -static VEC(internal_pragma_handler, heap) *registered_pragmas; +static vec<internal_pragma_handler> registered_pragmas; typedef struct { @@ -1163,10 +1156,8 @@ typedef struct const char *name; } pragma_ns_name; -DEF_VEC_O (pragma_ns_name); -DEF_VEC_ALLOC_O (pragma_ns_name, heap); -static VEC(pragma_ns_name, heap) *registered_pp_pragmas; +static vec<pragma_ns_name> registered_pp_pragmas; struct omp_pragma_def { const char *name; unsigned int id; }; static const struct omp_pragma_def omp_pragmas[] = { @@ -1202,13 +1193,10 @@ c_pp_lookup_pragma (unsigned int id, const char **space, const char **name) } if (id >= PRAGMA_FIRST_EXTERNAL - && (id < PRAGMA_FIRST_EXTERNAL - + VEC_length (pragma_ns_name, registered_pp_pragmas))) + && (id < PRAGMA_FIRST_EXTERNAL + registered_pp_pragmas.length ())) { - *space = VEC_index (pragma_ns_name, registered_pp_pragmas, - id - PRAGMA_FIRST_EXTERNAL).space; - *name = VEC_index (pragma_ns_name, registered_pp_pragmas, - id - PRAGMA_FIRST_EXTERNAL).name; + *space = registered_pp_pragmas[id - PRAGMA_FIRST_EXTERNAL].space; + *name = registered_pp_pragmas[id - PRAGMA_FIRST_EXTERNAL].name; return; } @@ -1233,15 +1221,14 @@ c_register_pragma_1 (const char *space, const char *name, ns_name.space = space; ns_name.name = name; - VEC_safe_push (pragma_ns_name, heap, registered_pp_pragmas, ns_name); - id = VEC_length (pragma_ns_name, registered_pp_pragmas); + registered_pp_pragmas.safe_push (ns_name); + id = registered_pp_pragmas.length (); id += PRAGMA_FIRST_EXTERNAL - 1; } else { - VEC_safe_push (internal_pragma_handler, heap, registered_pragmas, - ihandler); - id = VEC_length (internal_pragma_handler, registered_pragmas); + registered_pragmas.safe_push (ihandler); + id = registered_pragmas.length (); id += PRAGMA_FIRST_EXTERNAL - 1; /* The C++ front end allocates 6 bits in cp_token; the C front end @@ -1331,7 +1318,7 @@ c_invoke_pragma_handler (unsigned int id) pragma_handler_2arg handler_2arg; id -= PRAGMA_FIRST_EXTERNAL; - ihandler = &VEC_index (internal_pragma_handler, registered_pragmas, id); + ihandler = ®istered_pragmas[id]; if (ihandler->extra_data) { handler_2arg = ihandler->handler.handler_2arg; diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c index edeccce7a12..c8df1acf29f 100644 --- a/gcc/c-family/c-pretty-print.c +++ b/gcc/c-family/c-pretty-print.c @@ -1662,7 +1662,7 @@ pp_c_expression_list (c_pretty_printer *pp, tree e) /* Print out V, which contains the elements of a constructor. */ void -pp_c_constructor_elts (c_pretty_printer *pp, VEC(constructor_elt,gc) *v) +pp_c_constructor_elts (c_pretty_printer *pp, vec<constructor_elt, va_gc> *v) { unsigned HOST_WIDE_INT ix; tree value; @@ -1670,7 +1670,7 @@ pp_c_constructor_elts (c_pretty_printer *pp, VEC(constructor_elt,gc) *v) FOR_EACH_CONSTRUCTOR_VALUE (v, ix, value) { pp_expression (pp, value); - if (ix != VEC_length (constructor_elt, v) - 1) + if (ix != vec_safe_length (v) - 1) pp_separate_with (pp, ','); } } diff --git a/gcc/c-family/c-pretty-print.h b/gcc/c-family/c-pretty-print.h index 2f9f94af183..801663c3fc5 100644 --- a/gcc/c-family/c-pretty-print.h +++ b/gcc/c-family/c-pretty-print.h @@ -198,7 +198,7 @@ void pp_c_statement (c_pretty_printer *, tree); void pp_c_expression (c_pretty_printer *, tree); void pp_c_logical_or_expression (c_pretty_printer *, tree); void pp_c_expression_list (c_pretty_printer *, tree); -void pp_c_constructor_elts (c_pretty_printer *, VEC(constructor_elt,gc) *); +void pp_c_constructor_elts (c_pretty_printer *, vec<constructor_elt, va_gc> *); void pp_c_call_argument_list (c_pretty_printer *, tree); void pp_c_unary_expression (c_pretty_printer *, tree); void pp_c_cast_expression (c_pretty_printer *, tree); diff --git a/gcc/c-family/c-semantics.c b/gcc/c-family/c-semantics.c index 1a21ec17f83..dca7ec93add 100644 --- a/gcc/c-family/c-semantics.c +++ b/gcc/c-family/c-semantics.c @@ -37,7 +37,7 @@ push_stmt_list (void) { tree t; t = alloc_stmt_list (); - VEC_safe_push (tree, gc, stmt_list_stack, t); + vec_safe_push (stmt_list_stack, t); return t; } @@ -52,10 +52,10 @@ pop_stmt_list (tree t) nestings will be due to outstanding cleanups. */ while (1) { - u = VEC_pop (tree, stmt_list_stack); - if (!VEC_empty (tree, stmt_list_stack)) + u = stmt_list_stack->pop (); + if (!stmt_list_stack->is_empty ()) { - tree x = VEC_last (tree, stmt_list_stack); + tree x = stmt_list_stack->last (); STATEMENT_LIST_HAS_LABEL (x) |= STATEMENT_LIST_HAS_LABEL (u); } if (t == u) |