Commit 4f8c876d by Nathan Froyd Committed by Nathan Froyd

c-pragma.c (pending_redefinition): Declare.

	* c-pragma.c (pending_redefinition): Declare.  Declare a VEC of it.
	(pending_redefine_extname): Change type to a VEC.
	(add_to_renaming_pragma_list): Update for new type of
	pending_redefine_extname.
	(maybe_apply_pending_pragma): Likewise.

From-SVN: r163012
parent e7c64c7d
2010-08-08 Nathan Froyd <froydnj@codesourcery.com>
* c-pragma.c (pending_redefinition): Declare. Declare a VEC of it.
(pending_redefine_extname): Change type to a VEC.
(add_to_renaming_pragma_list): Update for new type of
pending_redefine_extname.
(maybe_apply_pending_pragma): Likewise.
2010-08-04 Arnaud Charlet <charlet@adacore.com> 2010-08-04 Arnaud Charlet <charlet@adacore.com>
* c-ada-spec.c (dump_ada_template): Mark underlying instance type as * c-ada-spec.c (dump_ada_template): Mark underlying instance type as
......
...@@ -424,7 +424,15 @@ maybe_apply_pending_pragma_weaks (void) ...@@ -424,7 +424,15 @@ maybe_apply_pending_pragma_weaks (void)
if it appears afterward, we have no way of knowing whether a modified if it appears afterward, we have no way of knowing whether a modified
DECL_ASSEMBLER_NAME is due to #pragma extern_prefix.) */ DECL_ASSEMBLER_NAME is due to #pragma extern_prefix.) */
static GTY(()) tree pending_redefine_extname; typedef struct GTY(()) pending_redefinition_d {
tree oldname;
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 void handle_pragma_redefine_extname (cpp_reader *); static void handle_pragma_redefine_extname (cpp_reader *);
...@@ -475,17 +483,23 @@ handle_pragma_redefine_extname (cpp_reader * ARG_UNUSED (dummy)) ...@@ -475,17 +483,23 @@ handle_pragma_redefine_extname (cpp_reader * ARG_UNUSED (dummy))
void void
add_to_renaming_pragma_list (tree oldname, tree newname) add_to_renaming_pragma_list (tree oldname, tree newname)
{ {
tree previous = purpose_member (oldname, pending_redefine_extname); unsigned ix;
if (previous) pending_redefinition *p;
{
if (TREE_VALUE (previous) != newname) for (ix = 0;
warning (OPT_Wpragmas, "#pragma redefine_extname ignored due to " VEC_iterate (pending_redefinition, pending_redefine_extname, ix, p);
"conflict with previous #pragma redefine_extname"); ix++)
return; if (oldname == p->oldname)
} {
if (p->newname != newname)
warning (OPT_Wpragmas, "#pragma redefine_extname ignored due to "
"conflict with previous #pragma redefine_extname");
return;
}
pending_redefine_extname p = VEC_safe_push (pending_redefinition, pending_redefine_extname, NULL);
= tree_cons (oldname, newname, pending_redefine_extname); p->oldname = oldname;
p->newname = newname;
} }
static GTY(()) tree pragma_extern_prefix; static GTY(()) tree pragma_extern_prefix;
...@@ -517,6 +531,8 @@ handle_pragma_extern_prefix (cpp_reader * ARG_UNUSED (dummy)) ...@@ -517,6 +531,8 @@ handle_pragma_extern_prefix (cpp_reader * ARG_UNUSED (dummy))
tree tree
maybe_apply_renaming_pragma (tree decl, tree asmname) maybe_apply_renaming_pragma (tree decl, tree asmname)
{ {
unsigned ix;
pending_redefinition *p;
tree *p, t; tree *p, t;
/* The renaming pragmas are only applied to declarations with /* The renaming pragmas are only applied to declarations with
...@@ -538,26 +554,32 @@ maybe_apply_renaming_pragma (tree decl, tree asmname) ...@@ -538,26 +554,32 @@ maybe_apply_renaming_pragma (tree decl, tree asmname)
"conflict with previous rename"); "conflict with previous rename");
/* Take any pending redefine_extname off the list. */ /* Take any pending redefine_extname off the list. */
for (p = &pending_redefine_extname; (t = *p); p = &TREE_CHAIN (t)) for (ix = 0;
if (DECL_NAME (decl) == TREE_PURPOSE (t)) VEC_iterate (pending_redefinition, pending_redefine_extname, ix, p);
ix++)
if (DECL_NAME (decl) == p->oldname)
{ {
/* Only warn if there is a conflict. */ /* Only warn if there is a conflict. */
if (strcmp (IDENTIFIER_POINTER (TREE_VALUE (t)), oldname)) if (strcmp (IDENTIFIER_POINTER (p->newname), oldname))
warning (OPT_Wpragmas, "#pragma redefine_extname ignored due to " warning (OPT_Wpragmas, "#pragma redefine_extname ignored due to "
"conflict with previous rename"); "conflict with previous rename");
*p = TREE_CHAIN (t); VEC_unordered_remove (pending_redefinition,
pending_redefine_extname, ix);
break; break;
} }
return 0; return 0;
} }
/* Find out if we have a pending #pragma redefine_extname. */ /* Find out if we have a pending #pragma redefine_extname. */
for (p = &pending_redefine_extname; (t = *p); p = &TREE_CHAIN (t)) for (ix = 0;
if (DECL_NAME (decl) == TREE_PURPOSE (t)) VEC_iterate (pending_redefinition, pending_redefine_extname, ix, p);
ix++)
if (DECL_NAME (decl) == p->oldname)
{ {
tree newname = TREE_VALUE (t); tree newname = p->newname;
*p = TREE_CHAIN (t); VEC_unordered_remove (pending_redefinition,
pending_redefine_extname, ix);
/* If we already have an asmname, #pragma redefine_extname is /* If we already have an asmname, #pragma redefine_extname is
ignored (with a warning if it conflicts). */ ignored (with a warning if it conflicts). */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment