[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] "identifier expected"? But not by GCC.
From: |
Dave Dodge |
Subject: |
Re: [Tinycc-devel] "identifier expected"? But not by GCC. |
Date: |
Fri, 17 Apr 2009 15:41:52 -0400 |
User-agent: |
Mutt/1.5.17 (2008-05-15) |
On Sat, Apr 18, 2009 at 03:23:31AM +0800, KHMan wrote:
> test.c:10: error: a label can only be part of a statement
> and a declaration is not a statement
>
> IIRC it's not ISO C90 compliant. Nothing wrong with tcc. I'll leave the
> digging up the ISO C standard to others.
According to the C grammar, a declaration is not a statement, but both
are block items. The reason you can mix them in other contexts is
because a braced block contains block items rather than just
statements:
compound-statement:
'{' block-item-list-opt '}'
block-item:
declaration
statement
A labeled statement is more strict and requires a statement rather
than a block item:
labeled-statement:
identifier ':' statement
'case' constant-expr ':' statement
'default' ':' statement
-Dave Dodge