This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: cpplib: expression parser
- To: Neil Booth <NeilB at earthling dot net>
- Subject: Re: cpplib: expression parser
- From: Zack Weinberg <zack at wolery dot cumb dot org>
- Date: Fri, 31 Mar 2000 23:28:28 -0800
- Cc: Horst von Brand <vonbrand at sleipnir dot valparaiso dot cl>, gcc-patches at gcc dot gnu dot org, Jonathan Larmour <jlarmour at redhat dot co dot uk>
- References: <zack@wolery.cumb.org> <200004010057.e310vJR01615@sleipnir.valparaiso.cl> <E12bDPN-0000Ov-00@monkey.rosenet.ne.jp>
On Sat, Apr 01, 2000 at 11:13:05AM +0900, Neil Booth wrote:
> Horst von Brand wrote:-
>
> > > > o "#if 1 + + + 1" was accepted.
> >
> > What is wrong with that? It should be taken as:
> >
> > 1 + (+(+1))
> >
> > (Unary '+'s), or am I totally lost here?
>
> Hmmm, on second thoughts I'm inclined to agree with you. Zack?
> Should I remove this test? If so, I'll take it out with patch 3.
Yes, I agree. An #if expression follows the same rules as an "integer
constant expression" in the language proper (with a few additional
restrictions, which aren't relevant here). I'm not 100% certain what
those are, but gcc accepts
int main(void) { printf("%d\n", 1 + + + 1); return 0; }
with no complaints, so I'd say it should be acceptable to #if, too.
Patches 2 and 3 can go in with this change and the change to error
handling we discussed earlier. Thanks for adding the huge comment
describing the algorithm in patch 3.
zw