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]
Other format: [Raw text]

Clarify documentation of GTY "tag" and "desc


This was unclear to me, so once I figured it out, I decided to say more 
about it:

2003-11-03  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* doc/gty.texi (tag, desc): Say more about role of desc values in
	selecting between tags.

*** doc/gty.texi	26 Jan 2003 20:56:09 -0000	1.11
--- doc/gty.texi	3 Nov 2003 23:41:36 -0000
***************
*** 133,138 ****
  
  The type machinery needs to be told which field of a @code{union} is
! currently active.  This is done by giving each field a constant @code{tag}
! value, and then specifying a discriminator using @code{desc}.  For example,
  @smallexample
  struct tree_binding GTY(())
--- 133,149 ----
  
  The type machinery needs to be told which field of a @code{union} is
! currently active.  This is done by giving each field a constant
! @code{tag} value, and then specifying a discriminator using @code{desc}.
! The value of the expression given by @code{desc} is compared against
! each @code{tag} value, each of which should be different.  If no
! @code{tag} is matched, the field marked with @code{default} is used if
! there is one, otherwise no field in the union will be marked.
! 
! In the @code{desc} option, the ``current structure'' is the union that
! it discriminates.  Use @code{%1} to mean the structure containing it.
! (There are no escapes available to the @code{tag} option, since it's
! supposed to be a constant.)
! 
! For example,
  @smallexample
  struct tree_binding GTY(())
***************
*** 142,158 ****
      tree GTY ((tag ("0"))) scope;
      struct cp_binding_level * GTY ((tag ("1"))) level;
!   @} GTY ((desc ("BINDING_HAS_LEVEL_P ((tree)&%0)"))) scope;
    tree value;
  @};
  @end smallexample
  
! In the @code{desc} option, the ``current structure'' is the union that
! it discriminates.  Use @code{%1} to mean the structure containing it.
! (There are no escapes available to the @code{tag} option, since it's
! supposed to be a constant.)
! 
! Each @code{tag} should be different.  If no @code{tag} is matched,
! the field marked with @code{default} is used if there is one, otherwise
! no field in the union will be marked.
  
  @findex param_is
--- 153,165 ----
      tree GTY ((tag ("0"))) scope;
      struct cp_binding_level * GTY ((tag ("1"))) level;
!   @} GTY ((desc ("BINDING_HAS_LEVEL_P ((tree)&%0)"))) xscope;
    tree value;
  @};
  @end smallexample
  
! In this example, the value of BINDING_HAS_LEVEL_P when applied to a
! @code{struct tree_binding *} is presumed to be 0 or 1.  If 1, the type
! mechanism will treat the field @code{level} as being present and if 0,
! will treat the field @code{scope} as being present.
  
  @findex param_is


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