Fix some printf like functions

This commit is contained in:
herman ten brugge 2020-05-05 09:00:24 +02:00
parent 8370bc03a1
commit 29ba50da29
5 changed files with 12 additions and 9 deletions

10
tcc.h
View File

@ -98,9 +98,11 @@ extern long double strtold (const char *__nptr, char **__endptr);
#ifdef _MSC_VER
# define NORETURN __declspec(noreturn)
# define ALIGNED(x) __declspec(align(x))
# define PRINTF_LIKE(x,y)
#else
# define NORETURN __attribute__((noreturn))
# define ALIGNED(x) __attribute__((aligned(x)))
# define PRINTF_LIKE(x,y) __attribute__ ((format (printf, (x), (y))))
#endif
/* gnu headers use to #define __attribute__ to empty for non-gcc compilers */
@ -1206,9 +1208,9 @@ PUB_FUNC char *tcc_strdup_debug(const char *str, const char *file, int line);
#define realloc(p, s) use_tcc_realloc(p, s)
#undef strdup
#define strdup(s) use_tcc_strdup(s)
PUB_FUNC void _tcc_error_noabort(const char *fmt, ...);
PUB_FUNC NORETURN void _tcc_error(const char *fmt, ...);
PUB_FUNC void _tcc_warning(const char *fmt, ...);
PUB_FUNC void _tcc_error_noabort(const char *fmt, ...) PRINTF_LIKE(1,2);
PUB_FUNC NORETURN void _tcc_error(const char *fmt, ...) PRINTF_LIKE(1,2);
PUB_FUNC void _tcc_warning(const char *fmt, ...) PRINTF_LIKE(1,2);
/* other utilities */
ST_FUNC void dynarray_add(void *ptab, int *nb_ptr, void *data);
@ -1218,7 +1220,7 @@ ST_FUNC void cstr_cat(CString *cstr, const char *str, int len);
ST_FUNC void cstr_wccat(CString *cstr, int ch);
ST_FUNC void cstr_new(CString *cstr);
ST_FUNC void cstr_free(CString *cstr);
ST_FUNC int cstr_printf(CString *cs, const char *fmt, ...);
ST_FUNC int cstr_printf(CString *cs, const char *fmt, ...) PRINTF_LIKE(2,3);
ST_FUNC void cstr_reset(CString *cstr);
ST_INLN void sym_free(Sym *sym);

View File

@ -108,7 +108,7 @@ static void asm_expr_unary(TCCState *s1, ExprValue *pe)
if (sym && (!sym->c || elfsym(sym)->st_shndx == SHN_UNDEF))
sym = sym->prev_tok;
if (!sym)
tcc_error("local label '%d' not found backward", n);
tcc_error("local label '%d' not found backward", (int)n);
} else {
/* forward */
if (!sym || (sym->c && elfsym(sym)->st_shndx != SHN_UNDEF)) {

View File

@ -2808,7 +2808,7 @@ ST_FUNC int tcc_load_object_file(TCCState *s1,
) {
invalid_reloc:
tcc_error_noabort("Invalid relocation entry [%2d] '%s' @ %.8x",
i, strsec + sh->sh_name, rel->r_offset);
i, strsec + sh->sh_name, (int)rel->r_offset);
goto fail;
}
rel->r_info = ELFW(R_INFO)(sym_index, type);

View File

@ -368,7 +368,8 @@ ST_FUNC void test_lvalue(void)
ST_FUNC void check_vstack(void)
{
if (vtop != vstack - 1)
tcc_error("internal compiler error: vstack leak (%d)", vtop - vstack + 1);
tcc_error("internal compiler error: vstack leak (%d)",
(int)(vtop - vstack + 1));
}
/* ------------------------------------------------------------------------- */
@ -8071,7 +8072,7 @@ static int decl0(int l, int is_for_loop_init, Sym *func_sym)
skip(',');
parse_mult_str(&error_str, "string constant");
if (c == 0)
tcc_error("%s", error_str.data);
tcc_error("%s", (char *)error_str.data);
cstr_free(&error_str);
skip(')');
static_assert_out:

View File

@ -3150,7 +3150,7 @@ static int paste_tokens(int t1, CValue *v1, int t2, CValue *v2)
if (is_space(tok))
continue;
tcc_warning("pasting \"%.*s\" and \"%s\" does not give a valid"
" preprocessing token", n, cstr.data, (char*)cstr.data + n);
" preprocessing token", n, (char *)cstr.data, (char*)cstr.data + n);
ret = 0;
break;
}