This is the mail archive of the gcc@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]

Re: How to GTYize a struct properly?


"Laurynas Biveinis" <laurynas.biveinis@gmail.com> writes:

> > > ../../gcc-boehm-custom-marking/gcc/value-prof.h:48: syntax error,
> > > unexpected '*', expecting ')'
> > >
> > > What should I do about it?
> > >
> >
> > Have to typedef the pointer due to gengtype silliness, IIRC.
> >
> > IE typedef struct histogram_value_t *histogram_value_t_p;
> >
> > then use histogram_value_t_p in the structure with the gty marker.
> 
> 
> Still not too good:
> 
> /* The value to measure.  */
> typedef struct histogram_value_t *histogram_value;
> struct histogram_value_t GTY(())
> {
>   struct
>     {
>       tree value;		/* The value to profile.  */
>       tree stmt;		/* Insn containing the value.  */
>       gcov_type *counters;		        /* Pointer to first counter.  */
>       histogram_value GTY((chain_next("%h.next"))) next;		/* Linked
> list pointer.  */
>     } hvalue;
>   enum hist_type type;			/* Type of information to measure.  */
>   unsigned n_counters;			/* Number of required counters.  */
>   union
>     {
>       struct
> 	{
> 	  int int_start;	/* First value in interval.  */
> 	  unsigned int steps;	/* Number of values in it.  */
> 	} intvl;	/* Interval histogram data.  */
>   } GTY((default("intvl"))) hdata;		/* Profiled information specific data.  */
> };
> 
> ../../gcc-boehm-custom-marking/gcc/value-prof.h:45: syntax error,
> unexpected '{', expecting ID
> 
> 
> The error is on the opening bracket on the first inner anonymous
> struct. Maybe this struct should be made non-inner or non-anonymous?
> Also, what's the deal with single-element union?

gengtype doesn't support anonymous structures or unions, you need to
give them a name.  (I don't remember if this is simply a limitation of
the existing implementation or if it's more fundamental.)


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