Oh, interesting - that didn't even occur to me.
Out of curiosity I just tried the same in msvc... the intellisense in Visual Studio highlights it as an error, but it builds and runs fine.
Brad
On 2024-01-18 02:15, grischka via Tinycc-devel wrote:
On 15.01.2024 00:34, Brad Robinson via Tinycc-devel wrote:
Hey All,
First post here. Firstly, thank you all for your work on this project. I discovered tcc just a month or so ago and really enjoying using it as a back-end code generator for a custom scripting language I'm working on.
Anyway, I noticed this small bug:
A variable declaration as the first statement in a switch case block fails when it shouldn't:
case 1: int z = 123; // This fails with "identifier expected" break;
Hi,well, yes, no. As a fact, a variable declaration is not astatement.
There's a pretty easy workaround, just insert an empty statement before.
case 1: ; // This fixes it int z = 123; break;
Yes, label before statement is allowed, also label before emptystatement, just not label before no statement.As for example "label: }" is not allowed either (in the theory).See also what gcc has to say:test.c: In function 'main':test.c:7:23: error: a label can only be part of a statement and a declaration is not a statement switch(a) case 1: int z; ^~~Which of course if a lot better than just "identifier expected"I would agree that far.-- gr
(this was build of the mob repo on github - not sure if that affects things).
Brad
_______________________________________________ Tinycc-devel mailing listTinycc-devel@nongnu.orghttps://lists.nongnu.org/mailman/listinfo/tinycc-devel
|