From 76cb1144ef91924c53c57ea71e6f67ce73ce1cc6 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Mon, 16 Sep 2013 14:48:33 +0200 Subject: Generate an error when a function is redefined Use one more bit in AttributeDef to differenciate between declared function (only its prototype is known) and defined function (its body is also known). This allows to generate an error in cases like: int f(){return 0;} int f(){return 1;} --- tcc.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tcc.h') diff --git a/tcc.h b/tcc.h index 98f28db..5ed3e21 100644 --- a/tcc.h +++ b/tcc.h @@ -389,9 +389,10 @@ typedef struct AttributeDef { func_export : 1, func_import : 1, func_args : 5, + func_proto : 1, mode : 4, weak : 1, - fill : 11; + fill : 10; struct Section *section; int alias_target; /* token */ } AttributeDef; @@ -401,6 +402,7 @@ typedef struct AttributeDef { #define FUNC_EXPORT(r) (((AttributeDef*)&(r))->func_export) #define FUNC_IMPORT(r) (((AttributeDef*)&(r))->func_import) #define FUNC_ARGS(r) (((AttributeDef*)&(r))->func_args) +#define FUNC_PROTO(r) (((AttributeDef*)&(r))->func_proto) #define FUNC_ALIGN(r) (((AttributeDef*)&(r))->aligned) #define FUNC_PACKED(r) (((AttributeDef*)&(r))->packed) #define ATTR_MODE(r) (((AttributeDef*)&(r))->mode) -- cgit v1.3.1