Need someone to look at a regression

Richard Earnshaw rearnsha@arm.com
Tue Aug 18 02:31:00 GMT 1998


> >>>>> Jeffrey A Law <law@cygnus.com> writes:
> 
>  >   In message < r2ww8bx9uq.fsf@happy.cygnus.com >you write:
>  >> law@cygnus.com (Jeffrey A Law) writes:
>  >> 
>  >> >    typedef SFtype __attribute__ ((mode (SF)));
>  >> > 
>  >> > We have an explicit type (SFmode), why in the hell would we ever
>  >> > want/need typedef int ....?
>  >> 
>  >> Isn't it that the __attribute__ stuff is, well, an attribute and it
>  >> should be possible to drop it?  Then yu would get
>  >> 
>  >> 	typedef SFtype;
>  >> 
>  >> which clearly is wrong.  You simply cannot leave out the base type.
> 
>  > I don't see that the "int" is a base type in this case.  How can you
>  > have an integer base type for a floating point mode?
> 
> In C,
> 
>   typedef SFtype;
> 
> is equivalent to
> 
>   typedef int SFtype;
> 
> by the implicit int rule.  In C++ and C9X, there is no such rule, so the
> above is ill-formed.
> 

It's a pity that the code below doesn't work.

typedef struct 
{
  unsigned x, y;
} foo __attribute__((mode (DF)));

foo bar()
{
  foo x;
  x.x = 0;
  x.y = 0;
  return x;
}

test.c: In function `bar':
test.c:9: request for member `x' in something not a structure or union
test.c:10: request for member `y' in something not a structure or union

This would be an extremely useful way of breaking down a floating point 
number into its component bit-fields, without having to mess around with a 
union.  It would certainly solve a problem I have at the moment, 
especially if the struct were passed to and from calls in the same way as 
a DFmode type.




More information about the Gcc mailing list