On 26/11/2025 00:31, Christian Schoenebeck wrote:
> On Tuesday, 25 November 2025 19:58:19 CET Greg Kurz wrote:
>> On Tue, 25 Nov 2025 19:21:00 +0500
>>
>> Andrey Erokhin <[email protected]> wrote:
>>>>> +    native_symlink:;
>>>>
>>>> Still has the terminating but unneeded semicolon
>>>
>>> I think I've addressed this in the v1 thread, with links to the C11 draft
>>> grammar. Can repeat in plain English: a label shall be followed by a
>>> statement. (No, declaration is not a statement)
>> My bad, I didn't see your answer.
>>
>> It is funny that I had to pass -pedantic to gcc to get a complaint (in plain
>> English as well) if I drop the semicolon :
>>
>> warning: a label can only be part of a statement and a declaration is not a
>> statement [-Wpedantic]
>>
>> Cheers,
> 
> Yes, I noticed that as well. GCC compiles fine without the semicolon, clang 
> OTOH errors:
> 
> ../hw/9pfs/9p-local.c:481:9: error: expected expression
>         char *dirpath = g_path_get_dirname(fs_path->data);
>         ^

I use clangd language server, so I don't even need to compile, I see the error 
immediately in the editor ;)

> Anyway, Andrey is right of course. The C standard defines a "labeled-
> statement" as
> 
>   identifier : statement
>   ...
> 
> and the subsequent line in the patch is a declaration, not a statement.
> 
> But I also understand if GCC developers relaxed this rule. Because it "feels" 
> like both, a declaration and a statement. Interesting, because usually it's 
> clang to be more relaxed than GCC.

Probably GCC allowed mixing declarations and statements in a block way before 
C99, in C++-like way, which has statement → declaration-statement → 
block-declaration production
(C99+ uses block-item → declaration|statement)

Reply via email to