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]

Re: alias.c:nonoverlapping_component_refs_p


Richard Henderson wrote:-

> Hum.  I'd have thought variant records would have been implemented via
> nested RECORD and UNION types.  Loosely,
> 
>    type Thread_Attributes (Bound_To_Sproc : Boolean) is
>       record
>          Thread_Resources : Resource_Vector_T := NO_RESOURCES;
>          Thread_Timeslice : Duration          := 0.0;
>          case Bound_To_Sproc is
>             when False =>
>                null;
>             when True   =>
>                Sproc : sproc_t;
>          end case;
>       end record;
> 
> might be represented as
> 
>   typedef struct {
>     Resource_Vector_T	Thread_Resources;
>     Duration		Thread_Timeslice;
>     Boolean		Bound_To_Sproc;
>     union {
>       struct {
>       } f;
>       struct {
> 	sproc_t		Sproc;
>       } t;
>     } u;
>   } Thread_Attributes;
> 
> where the compiler automatically transforms
> 
>   Thread_Attributes.Sproc
> 
> to
> 
>   Thread_Attributes.u.t.Sproc
> 
> plus whatever sanity checking vs Bound_To_Sproc are required
> by the language.

I thought so too; particularly now we have working anonymous unions,
modulo a minor PR of Joseph's.

Neil.


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