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]

Re: cpplib: expression parser


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

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