From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dale Johannesen To: Aldy Hernandez Cc: Dale Johannesen , "Joseph S. Myers" , Stan Shebs , gcc@gcc.gnu.org Subject: Re: Target-specific Front-Ends? (Was: front end changes for altivec) Date: Tue, 27 Nov 2001 14:46:00 -0000 Message-ID: <82DD5AC8-E388-11D5-9854-003065C86F94@apple.com> References: X-SW-Source: 2001-11/msg01402.html Message-ID: <20011127144600.6t-piynIQWknYhO6srA8wus19u1nMnc2dGZE2G_mUvw@z> On Tuesday, November 27, 2001, at 01:58 PM, Aldy Hernandez wrote: >>>>>> "Joseph" == Joseph S Myers 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 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.