|
From: | Cayle Graumann |
Subject: | Re: [Tinycc-devel] TCC on new ARM EABI (ARMEL) |
Date: | Tue, 19 Sep 2006 09:43:53 -0500 |
On Sun, Sep 17, 2006 at 10:45:06PM -0500, Cayle Graumann wrote:
> On 9/17/06, Daniel Glöckner <address@hidden> wrote:
> Adding the extra set of parentheses in the define was the solution I
> came up with to get it to compile also. The real question is why does GCC
> allow it?
Because the grammar makes it unambiguous. The parentheses are not
supposed to be needed:
sizeof (x)/sizeof (x)[0]
The [0] can only be applied to a postfix-_expression_. None of these is
a postfix-_expression_:
sizeof (x)/sizeof (x) multiplicative-_expression_
(x)/sizeof (x) multiplicative-_expression_
sizeof (x) unary-_expression_
The only way it parses is:
(x) primary-_expression_
^^^[0] postfix-_expression_
sizeof ^^^^^^ unary-_expression_
(x) primary-_expression_
sizeof ^^^ unary-_expression_
^^^^^^^^^^/^^^^^^^^^^^^^ multiplicative-_expression_
Which is what the code intends.
> >But then we can go further and ask if "sizeof (char)7" is a legal C
> >_expression_...
No, that's always an error. For example:
char type-name
(^^^^)7 cast-_expression_
sizeof ^^^^^^^ error: sizeof can't be applied to a cast-_expression_
or
char type-name
sizeof (^^^^) unary-_expression_
^^^^^^^^^^^^^7 error: unary-_expression_ followed by constant
-Dave Dodge
_______________________________________________
Tinycc-devel mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/tinycc-devel
[Prev in Thread] | Current Thread | [Next in Thread] |