From 673befd2d7745a90c1c4fcb6d2f0e266c04f8c97 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Fri, 20 Sep 2013 22:49:49 +0200 Subject: [PATCH] Report error when redefining enumerator Prevent the following code from compiling: enum color {RED, GREEN, BLUE}; enum rgb {RED, G, B}; --- tccgen.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tccgen.c b/tccgen.c index 77ff87c0..0f0aac58 100644 --- a/tccgen.c +++ b/tccgen.c @@ -2786,6 +2786,10 @@ static void struct_decl(CType *type, int u, int tdef) v = tok; if (v < TOK_UIDENT) expect("identifier"); + ss = sym_find(v); + if (ss) + tcc_error("redefinition of enumerator '%s'", + get_tok_str(v, NULL)); next(); if (tok == '=') { next(); -- 2.11.4.GIT