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: Target-specific Front-Ends? (Was: front end changes for altivec)



On Tuesday, November 27, 2001, at 01:58 PM, Aldy Hernandez wrote:

>>>>>> "Joseph" == Joseph S Myers <jsm28@cam.ac.uk> writes:
>
>
>> * With context-sensitive keywords, after "typedef int vector;", is vector
>> a keyword or a typedef?
>
> You can't typedef vector in the altivec specs.

The Moto docs (PIM on the website) give two ways to do it, in 2.2.1 and 2.
2.2.
You're apparently trying to use 2.2.1, where "vector" is a predefined 
macro.
Apple/Moto's implementation is based on 2.2.2, where "vector" is a 
context-sensitive
keyword.  IMO the 2.2.2 way is clearly better, well, less bad anyway; it 
does
allow the user to use 'vector' in many other places, as he is supposed to 
be able
to do.  In particular 'typedef int vector;' works, and AFAIK the STL use of
"vector" also works, although I don't think anybody's exercised it much.  
The
PIM doesn't explain things very well, but what happens is that "vector" is 
a
keyword only when it's at the beginning of a type specification, and only
when followed by certain other keywords, as listed in the PIM.  Thus:

typedef int vector;
vector x;               /* int */
vector unsigned int y;  /* Altivec vector */

And sure enough it works that way.  I think the way the new syntax works,
it is actually unambiguous, although that isn't obvious (Ira eventually 
convinced
me :)  I further think the context-sensitive keyword implementation does 
not break
any standard-conforming use of "vector" as an identifier; it only makes 
legal
some constructs that are errors according to the standard.  (This does not
mean I think it was a good idea; I don't.  But it does work.)

| "Joseph" == Joseph S Myers <jsm28@cam.ac.uk> writes:
|
| * With context-sensitive keywords, after "int vector;", is "(vector)+1" 
to
| be interpreted as addition, or a cast (which would seem to parse 
according
| to the syntax, but violate constraints)?

Addition.  (vector) is not a cast because "vector" does not indicate a 
type here,
since it isn't followed by any of the other magic words.


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