I am a rare poster here – but I think your patch leads to all sorts of problems.

Please revert it/don’t commit it.

From: [email protected] 
[mailto:[email protected]] On 
Behalf Of Amine Najahi
Sent: Friday, March 11, 2016 12:13 PM
To: [email protected]
Subject: Re: [Tinycc-devel] MAJOR bug: tcc doesn't detect duplicate cases in 
switch statements

Hi Arnold and tcc folks,

Perhaps surprisingly, correcting this bug is quite costly.
Here is a tentative patch. I find it messy but working with dynamic data
and passing the cases to the block function are necessary to handle
an "unlimited number" of cases and nested switch blocks.

Also, since the 'block' function is starting to have too many arguments, I
suggest to create a structure that assembles related arguments such
that def_sym, case_sym, cases, and cases_cnt, and any other...

Does that sound ok?

Regards,
Amine


On Thu, Mar 10, 2016 at 2:41 PM, <[email protected]<mailto:[email protected]>> 
wrote:
Hi All.

On the latest mob:

$ cat foo.c
int main(int argc, char**argv)
{
        int a;

        switch (a) {
        case 1:
        case 2:
                break;
        case 3:
                break;
        case 1:
                break;
        default:
                break;
        }

        return 0;
}
$ PATH=/tmp/tcc/bin:$PATH tcc foo.c
$

$ gcc foo.c -o foo
foo.c: In function ‘main’:
foo.c:11:2: error: duplicate case value
  case 1:
  ^
foo.c:6:2: error: previously used here
  case 1:
  ^

This is pretty serious....

Thanks,

Arnold

_______________________________________________
Tinycc-devel mailing list
[email protected]<mailto:[email protected]>
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to