aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Warkentin <andrey.warkentin@gmail.com>2017-03-28 02:51:39 -0400
committerAndrei Warkentin <awarkentin@awarkentin-mba.local>2017-04-25 13:55:18 +0300
commit63b2f907bd9f8ad82b2cfaf8a34497578877253b (patch)
tree8424ba19fad0a1d6812fc61dde9ecfd2f81374d2
parent91cd148a05e2c492a02eb77b12a2581b87bc9822 (diff)
downloadtinycc-63b2f907bd9f8ad82b2cfaf8a34497578877253b.tar.gz
tinycc-63b2f907bd9f8ad82b2cfaf8a34497578877253b.tar.bz2
tcc: fixup clang warnings
The O(xxx) stuff in i386-asm.c had me scratching my head. Extracting the macro and trying it out in a separate program doesn't give me any warnings, so I'm confused about what could be going on there. Any cast will make things happy. I used a uint64_t to catch actual cases of overflow, which will still cause a -Wconstant-conversion warning. Signed-off-by: Andrei Warkentin <andrey.warkentin@gmail.com>
-rw-r--r--Makefile2
-rw-r--r--arm-link.c2
-rw-r--r--arm64-link.c2
-rw-r--r--c67-link.c2
-rw-r--r--i386-asm.c10
-rw-r--r--i386-link.c2
-rw-r--r--tcc.h5
-rw-r--r--tccelf.c2
-rw-r--r--tccpp.c33
-rw-r--r--x86_64-link.c2
10 files changed, 17 insertions, 45 deletions
diff --git a/Makefile b/Makefile
index 8de469a..b8e749c 100644
--- a/Makefile
+++ b/Makefile
@@ -69,7 +69,7 @@ else
endif
ifeq ($(TARGETOS),Darwin)
- CFLAGS += -Wl,-flat_namespace,-undefined,warning
+ LDFLAGS += -flat_namespace -undefined warning
export MACOSX_DEPLOYMENT_TARGET:=10.2
endif
diff --git a/arm-link.c b/arm-link.c
index 5e9c698..002d13e 100644
--- a/arm-link.c
+++ b/arm-link.c
@@ -166,7 +166,7 @@ ST_FUNC void relocate_plt(TCCState *s1)
void relocate_init(Section *sr) {}
-void relocate(TCCState *s1, ElfW_Rel *rel, int type, char *ptr, addr_t addr, addr_t val)
+void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val)
{
ElfW(Sym) *sym;
int sym_index;
diff --git a/arm64-link.c b/arm64-link.c
index 739d56e..179fb14 100644
--- a/arm64-link.c
+++ b/arm64-link.c
@@ -153,7 +153,7 @@ ST_FUNC void relocate_plt(TCCState *s1)
void relocate_init(Section *sr) {}
-void relocate(TCCState *s1, ElfW_Rel *rel, int type, char *ptr, addr_t addr, addr_t val)
+void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val)
{
int sym_index = ELFW(R_SYM)(rel->r_info);
#ifdef DEBUG_RELOC
diff --git a/c67-link.c b/c67-link.c
index ce45269..32610e0 100644
--- a/c67-link.c
+++ b/c67-link.c
@@ -96,7 +96,7 @@ ST_FUNC void relocate_plt(TCCState *s1)
void relocate_init(Section *sr) {}
-void relocate(TCCState *s1, ElfW_Rel *rel, int type, char *ptr, addr_t addr, addr_t val)
+void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val)
{
switch(type) {
case R_C60_32:
diff --git a/i386-asm.c b/i386-asm.c
index 0c0985e..87d14bd 100644
--- a/i386-asm.c
+++ b/i386-asm.c
@@ -221,7 +221,7 @@ static const uint8_t segment_prefixes[] = {
static const ASMInstr asm_instrs[] = {
#define ALT(x) x
/* This removes a 0x0f in the second byte */
-#define O(o) ((((o) & 0xff00) == 0x0f00) ? ((((o) >> 8) & ~0xff) | ((o) & 0xff)) : (o))
+#define O(o) ((uint64_t) ((((o) & 0xff00) == 0x0f00) ? ((((o) >> 8) & ~0xff) | ((o) & 0xff)) : (o)))
/* This constructs instr_type from opcode, type and group. */
#define T(o,i,g) ((i) | ((g) << OPC_GROUP_SHIFT) | ((((o) & 0xff00) == 0x0f00) ? OPC_0F : 0))
#define DEF_ASM_OP0(name, opcode)
@@ -278,7 +278,7 @@ static inline int get_reg_shift(TCCState *s1)
}
#ifdef TCC_TARGET_X86_64
-static int asm_parse_numeric_reg(int t, int *type)
+static int asm_parse_numeric_reg(int t, unsigned int *type)
{
int reg = -1;
if (t >= TOK_IDENT && t < tok_ident) {
@@ -317,7 +317,7 @@ static int asm_parse_numeric_reg(int t, int *type)
}
#endif
-static int asm_parse_reg(int *type)
+static int asm_parse_reg(unsigned int *type)
{
int reg = 0;
*type = 0;
@@ -453,7 +453,7 @@ static void parse_operand(TCCState *s1, Operand *op)
op->e.pcrel = 0;
}
if (tok == '(') {
- int type = 0;
+ unsigned int type = 0;
next();
if (tok != ',') {
op->reg = asm_parse_reg(&type);
@@ -1688,7 +1688,7 @@ ST_FUNC void asm_clobber(uint8_t *clobber_regs, const char *str)
int reg;
TokenSym *ts;
#ifdef TCC_TARGET_X86_64
- int type;
+ unsigned int type;
#endif
if (!strcmp(str, "memory") ||
diff --git a/i386-link.c b/i386-link.c
index c232f39..bb50297 100644
--- a/i386-link.c
+++ b/i386-link.c
@@ -159,7 +159,7 @@ void relocate_init(Section *sr)
qrel = (ElfW_Rel *) sr->data;
}
-void relocate(TCCState *s1, ElfW_Rel *rel, int type, char *ptr, addr_t addr, addr_t val)
+void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val)
{
int sym_index, esym_index;
diff --git a/tcc.h b/tcc.h
index 5b9d4a3..41ad1ab 100644
--- a/tcc.h
+++ b/tcc.h
@@ -721,7 +721,8 @@ struct TCCState {
enum {
LINE_MACRO_OUTPUT_FORMAT_GCC,
LINE_MACRO_OUTPUT_FORMAT_NONE,
- LINE_MACRO_OUTPUT_FORMAT_STD
+ LINE_MACRO_OUTPUT_FORMAT_STD,
+ LINE_MACRO_OUTPUT_FORMAT_P10 = 11
} Pflag; /* -P switch */
char dflag; /* -dX value */
@@ -1446,7 +1447,7 @@ ST_FUNC int code_reloc (int reloc_type);
ST_FUNC int gotplt_entry_type (int reloc_type);
ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr);
ST_FUNC void relocate_init(Section *sr);
-ST_FUNC void relocate(TCCState *s1, ElfW_Rel *rel, int type, char *ptr, addr_t addr, addr_t val);
+ST_FUNC void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val);
ST_FUNC void relocate_plt(TCCState *s1);
/* ------------ xxx-gen.c ------------ */
diff --git a/tccelf.c b/tccelf.c
index 6a27495..654d43a 100644
--- a/tccelf.c
+++ b/tccelf.c
@@ -787,7 +787,7 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s)
tgt += rel->r_addend;
#endif
addr = s->sh_addr + rel->r_offset;
- relocate(s1, rel, type, ptr, addr, tgt);
+ relocate(s1, rel, type, ptr, addr, tgt);
}
/* if the relocation is allocated, we change its symbol table */
if (sr->sh_flags & SHF_ALLOC)
diff --git a/tccpp.c b/tccpp.c
index 7e5cdcf..a27ca42 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -1021,35 +1021,6 @@ ST_FUNC void restore_parse_state(ParseState *s)
tokc = s->tokc;
}
-/* return the number of additional 'ints' necessary to store the
- token */
-static inline int tok_size(const int *p)
-{
- switch(*p) {
- /* 4 bytes */
- case TOK_CINT:
- case TOK_CUINT:
- case TOK_CCHAR:
- case TOK_LCHAR:
- case TOK_CFLOAT:
- case TOK_LINENUM:
- return 1 + 1;
- case TOK_STR:
- case TOK_LSTR:
- case TOK_PPNUM:
- case TOK_PPSTR:
- return 1 + ((sizeof(CString) + ((CString *)(p+1))->size + 3) >> 2);
- case TOK_CDOUBLE:
- case TOK_CLLONG:
- case TOK_CULLONG:
- return 1 + 2;
- case TOK_CLDOUBLE:
- return 1 + LDOUBLE_SIZE / 4;
- default:
- return 1 + 0;
- }
-}
-
/* token string handling */
ST_INLN void tok_str_new(TokenString *s)
@@ -2615,7 +2586,7 @@ maybe_newline:
} else {
/* slower case */
cstr_reset(&tokcstr);
- cstr_cat(&tokcstr, p1, len);
+ cstr_cat(&tokcstr, (char *) p1, len);
p--;
PEEKC(c, p);
parse_ident_slow:
@@ -3732,7 +3703,7 @@ ST_FUNC int tcc_preprocess(TCCState *s1)
/* Credits to Fabrice Bellard's initial revision to demonstrate its
capability to compile and run itself, provided all numbers are
given as decimals. tcc -E -P10 will do. */
- if (s1->Pflag == 1 + 10)
+ if (s1->Pflag == LINE_MACRO_OUTPUT_FORMAT_P10)
parse_flags |= PARSE_FLAG_TOK_NUM, s1->Pflag = 1;
#ifdef PP_BENCH
diff --git a/x86_64-link.c b/x86_64-link.c
index 27cad93..5f7cec3 100644
--- a/x86_64-link.c
+++ b/x86_64-link.c
@@ -157,7 +157,7 @@ void relocate_init(Section *sr)
qrel = (ElfW_Rel *) sr->data;
}
-void relocate(TCCState *s1, ElfW_Rel *rel, int type, char *ptr, addr_t addr, addr_t val)
+void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val)
{
int sym_index, esym_index;