* C99 parsing error?
@ 2003-05-18 8:52 Jamie Lokier
2003-05-18 10:27 ` Neil Booth
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jamie Lokier @ 2003-05-18 8:52 UTC (permalink / raw)
To: gcc
Is it really not permitted to write this in C99?:
while (--length >= 0)
{
loop:
int byte = *data++;
GCC 3.2.2 reports: parse error before "int"
If I replace "loop:" with "loop:;", it's fine.
Perhaps GCC is correct to reject this, but it is surprising.
-- Jamie
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: C99 parsing error?
2003-05-18 8:52 C99 parsing error? Jamie Lokier
@ 2003-05-18 10:27 ` Neil Booth
2003-05-18 14:19 ` Joseph S. Myers
2003-05-18 15:22 ` Falk Hueffner
2 siblings, 0 replies; 4+ messages in thread
From: Neil Booth @ 2003-05-18 10:27 UTC (permalink / raw)
To: Jamie Lokier; +Cc: gcc
Jamie Lokier wrote:-
> Is it really not permitted to write this in C99?:
>
> while (--length >= 0)
> {
> loop:
> int byte = *data++;
>
> GCC 3.2.2 reports: parse error before "int"
> If I replace "loop:" with "loop:;", it's fine.
> Perhaps GCC is correct to reject this, but it is surprising.
No, your code is fine.
Neil.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: C99 parsing error?
2003-05-18 8:52 C99 parsing error? Jamie Lokier
2003-05-18 10:27 ` Neil Booth
@ 2003-05-18 14:19 ` Joseph S. Myers
2003-05-18 15:22 ` Falk Hueffner
2 siblings, 0 replies; 4+ messages in thread
From: Joseph S. Myers @ 2003-05-18 14:19 UTC (permalink / raw)
To: Jamie Lokier; +Cc: gcc
On Sun, 18 May 2003, Jamie Lokier wrote:
> Is it really not permitted to write this in C99?:
>
> while (--length >= 0)
> {
> loop:
> int byte = *data++;
>
> GCC 3.2.2 reports: parse error before "int"
> If I replace "loop:" with "loop:;", it's fine.
> Perhaps GCC is correct to reject this, but it is surprising.
A compound statement is a sequence of statements and declarations; only
statements can have labels; see 6.8.1 and 6.8.2. The existing GCC
extension of attributes on labels means that we don't accept labels on
declarations as an extension either.
--
Joseph S. Myers
jsm28@cam.ac.uk
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: C99 parsing error?
2003-05-18 8:52 C99 parsing error? Jamie Lokier
2003-05-18 10:27 ` Neil Booth
2003-05-18 14:19 ` Joseph S. Myers
@ 2003-05-18 15:22 ` Falk Hueffner
2 siblings, 0 replies; 4+ messages in thread
From: Falk Hueffner @ 2003-05-18 15:22 UTC (permalink / raw)
To: Jamie Lokier; +Cc: gcc
Jamie Lokier <jamie@shareable.org> writes:
> Is it really not permitted to write this in C99?:
>
> while (--length >= 0)
> {
> loop:
> int byte = *data++;
>
> GCC 3.2.2 reports: parse error before "int"
> If I replace "loop:" with "loop:;", it's fine.
That is indeed not permitted. C99 allows mixing statements and
declarations within blocks, but a declaration *is* not a statement,
and a label must be followed by a statement.
--
Falk
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-05-18 14:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-18 8:52 C99 parsing error? Jamie Lokier
2003-05-18 10:27 ` Neil Booth
2003-05-18 14:19 ` Joseph S. Myers
2003-05-18 15:22 ` Falk Hueffner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).