rui314 / 8cc

A Small C Compiler
MIT License
6.13k stars 740 forks source link

Missing errors #53

Closed rdebath closed 9 years ago

rdebath commented 9 years ago

Minor one for now, this should generate a "duplicate case label" or similar error.

int
func(int n)
{
    switch (n) {
    case 2 + 2:
        return 1;
    case 4:
        return 2;
    }
    return 0;
}
rui314 commented 9 years ago

Yup. Case labels are actually ranges because of GNU extension https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html, we need to also warn on something like 3 ... 7 and 5 ... 10.

rui314 commented 9 years ago

Fixed in 1a4f62507fe4cd8f57061ff773125b0512935c22.