[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] Lexer conditionally doesn't require "case" in "switch
From: |
Michael Matz |
Subject: |
Re: [Tinycc-devel] Lexer conditionally doesn't require "case" in "switch" |
Date: |
Wed, 9 Nov 2016 15:52:27 +0100 (CET) |
User-agent: |
Alpine 2.20 (LSU 67 2015-01-07) |
Hi,
On Tue, 8 Nov 2016, Steffen Nurpmeso wrote:
> a tcc(1) compiled on June 6th as well as one of [mob:3054a76] (as
> well as one of [master], accidentally) fails to fail on the
> attached file.
The file being:
enum{ a_0, a_1, a255 };
int
main(int argc, char **argv){
switch(argc){
a_0: return 0;
a_1: return 1;
a_255: return 255;
}
}
Why should it fail? This is valid (albeit silly) code with three dead
labelled statements. switch cases are nothing else than normal labeled
statements (with a special label, though), and nothing says that a switch
must have any cases. Also the namespaces for labels and decls are
separate, so it's also valid to have enums and labels of the same name.
Ciao,
Michael.