This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Compiler identifier hashtable improvements (and ObjC cleanup)


On Thu, May 17, 2001 at 07:31:11AM +0100, Neil Booth wrote:
> Zack Weinberg wrote:-
> 
> > Yeah, you can stomp on the flags - I am fairly sure only two of them
> > are used for IDENTIFIER_NODEs.  But be careful, because a language
> > might have decided to recycle them for its own purposes.
> 
> I think the C front end uses about 5 flags - I updated the comments in
> tree.h to reflect what I'd discovered on my wanderings as part of the
> patch.

Also note that the flags are in blocks of seven, not eight, not
counting the 'unsigned dummy;' at the end.  So there's two more bits
in that 32-bit word that are inaccessible.  A change like this is
probably in order:

===================================================================
Index: tree.h
--- tree.h	2001/05/16 06:22:15	1.238
+++ tree.h	2001/05/17 06:50:10
@@ -138,6 +138,7 @@ struct tree_common
   unsigned readonly_flag : 1;
   unsigned unsigned_flag : 1;
   unsigned asm_written_flag: 1;
+  unsigned reserved_1 : 1;	/* reserved for future expansion */
 
   unsigned used_flag : 1;
   unsigned nothrow_flag : 1;
@@ -146,6 +147,7 @@ struct tree_common
   unsigned private_flag : 1;
   unsigned protected_flag : 1;
   unsigned bounded_flag : 1;
+  unsigned reserved_2 : 1;	/* reserved for future expansion */
 
   unsigned lang_flag_0 : 1;
   unsigned lang_flag_1 : 1;
@@ -154,10 +156,7 @@ struct tree_common
   unsigned lang_flag_4 : 1;
   unsigned lang_flag_5 : 1;
   unsigned lang_flag_6 : 1;
-  /* This flag is presently unused.  However, language front-ends
-     should not make use of this flag; it is reserved for future
-     expansion.  */
-  unsigned dummy : 1;
+  unsigned lang_flag_7 : 1;
 };
 
 /* The following table lists the uses of each of the above flags and
@@ -643,6 +642,7 @@ extern void tree_class_check_failed PARA
 #define TREE_LANG_FLAG_4(NODE) ((NODE)->common.lang_flag_4)
 #define TREE_LANG_FLAG_5(NODE) ((NODE)->common.lang_flag_5)
 #define TREE_LANG_FLAG_6(NODE) ((NODE)->common.lang_flag_6)
+#define TREE_LANG_FLAG_7(NODE) ((NODE)->common.lang_flag_7)
 
 /* Define additional fields and accessors for nodes representing constants.  */
 
Someone probably miscounted them in the past.

> > I'm just confused about why the case where you allocate the
> > identifier_node and then set its code to ERROR_MARK is necessary.  I'm
> > also nervous about how that will interact with GC.
> 
> Right, see my followup cleanup patch (not yet approved).  We'll
> ggc-mark the node as normal.  An ERROR_MARK node doesn't GC any of its
> members, since it doesn't have any.  A newly created IDENTIFIER_NODE
> doesn't have any non-NULL members either.  So that part seems OK to
> me.

*nod*

...
> In future, the only way they'll be possible is when cpplib creates
> them through some as-yet non-existent interface.  They'll still not be
> visible from the front ends: what is currently yylexname () in c-lex.c
> will die, and in its place one or two lines of code will switch the
> node's code to IDENTIFIER_NODE to simulate a get_identifier () call.

Okay, that makes more sense now.  Thanks for clarifying.

> > Oh, okay, but then what happens if you write 'int oneway;' ?
> 
> $ cat /tmp/test.m
> int oneway;
> int byref;
> $ ./xgcc -B./ /tmp/test.m -c
> $
> 
> Seems OK.  Cool :-)

Probably a larger piece of code that uses each of the occasionally-
reserved identifiers in a context where they're not reserved, should
be added to the ObjC test suite.  Also, not all of them are being
tested in their reserved context - in, out, inout, byref need tests.

-- 
zw             But your argument is simply post hoc ergo ante hoc.
               	-- Umberto Eco, _Foucault's Pendulum_


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]