This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: bad definition of IDENTIFIER_GLOBAL_VALUE
- To: bothner at cygnus dot com
- Subject: Re: bad definition of IDENTIFIER_GLOBAL_VALUE
- From: "Martin v. Loewis" <loewis at informatik dot hu-berlin dot de>
- Date: Sun, 29 Mar 1998 20:43:49 +0200
- CC: egcs at cygnus dot com
- References: <199803280029.QAA09830@cygnus.com>
> This is inefficient, since it creates new CPLUS_BINDINGs
> unnecessarily. Most uses of IDENTIFIER_GLOBAL_VALUE are in
> an rvalue context, where creating a new binding is useless.
I'm not convinced that it is really bad. It creates the binding only
one the first lookup, later lookups will return the previous
binding. Also, if you look for the global name, you either expect to
find something there, or plan to place something there soon, or the
program is in error (there may be other cases, but my point is that
they are rare).
If this turns out to be a problem, the fix is obvious: provide
different access functions for read and write. I'd like to collect
some statistics first.
> Worse, print_lang_identifier invokes IDENTIFIER_GLOBAL_VALUE.
Yes, this is unfortunate. The patch below will fix it, and I hope to
see it in egcs soon. It relies on a different patch
(lang_print_xnode), that's why it didn't get integrated in the first
round. Printing nodes should be fail-safe, and I agree it currently
isn't. Sorry about that.
Martin
Index: ptree.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/ptree.c,v
retrieving revision 1.4
diff -u -p -r1.4 ptree.c
--- ptree.c 1998/03/03 03:24:43 1.4
+++ ptree.c 1998/03/27 12:22:05
@@ -153,7 +153,7 @@ print_lang_identifier (file, node, inden
tree node;
int indent;
{
- print_node (file, "global", IDENTIFIER_GLOBAL_VALUE (node), indent + 4);
+ print_node (file, "bindings", IDENTIFIER_NAMESPACE_BINDINGS (node), indent + 4);
print_node (file, "class", IDENTIFIER_CLASS_VALUE (node), indent + 4);
print_node (file, "local", IDENTIFIER_LOCAL_VALUE (node), indent + 4);
print_node (file, "label", IDENTIFIER_LABEL_VALUE (node), indent + 4);