[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] TCC on new ARM EABI (ARMEL)

From: Dave Dodge
Subject: Re: [Tinycc-devel] TCC on new ARM EABI (ARMEL)
Date: Tue, 19 Sep 2006 00:36:10 -0400
User-agent: Mutt/1.4.2i

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

          char      type-name
  sizeof (^^^^)     unary-expression
  ^^^^^^^^^^^^^7    error: unary-expression followed by constant

                                                  -Dave Dodge

reply via email to

[Prev in Thread] Current Thread [Next in Thread]