diff options
Diffstat (limited to 'gcc/c-family/c-pragma.c')
-rw-r--r-- | gcc/c-family/c-pragma.c | 75 |
1 files changed, 31 insertions, 44 deletions
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; |