History

Fix some printf like functions

herman ten brugge committed 6 years ago

Commit 29ba50d1 parent 8370bc05 files · +12 −9Browse files

Unified · Split

5 files
  1. tcc.h +6 −4
  2. tccasm.c +1 −1
  3. tccelf.c +1 −1
  4. tccgen.c +3 −2
  5. tccpp.c +1 −1
tcc.h+6−4
@@ -98,9 +98,11 @@ extern long double strtold (const char *__nptr, char **__endptr); · 97 unmodified lines
9898 #ifdef _MSC_VER
9999 # define NORETURN __declspec(noreturn)
100100 # define ALIGNED(x) __declspec(align(x))
101+# define PRINTF_LIKE(x,y)
101102 #else
102103 # define NORETURN __attribute__((noreturn))
103104 # define ALIGNED(x) __attribute__((aligned(x)))
105+# define PRINTF_LIKE(x,y) __attribute__ ((format (printf, (x), (y))))
104106 #endif
105107
106108 /* 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); · 1099 unmodified lines
12061208 #define realloc(p, s) use_tcc_realloc(p, s)
12071209 #undef strdup
12081210 #define strdup(s) use_tcc_strdup(s)
1209−PUB_FUNC void _tcc_error_noabort(const char *fmt, ...);
1210−PUB_FUNC NORETURN void _tcc_error(const char *fmt, ...);
1211−PUB_FUNC void _tcc_warning(const char *fmt, ...);
1211+PUB_FUNC void _tcc_error_noabort(const char *fmt, ...) PRINTF_LIKE(1,2);
1212+PUB_FUNC NORETURN void _tcc_error(const char *fmt, ...) PRINTF_LIKE(1,2);
1213+PUB_FUNC void _tcc_warning(const char *fmt, ...) PRINTF_LIKE(1,2);
12121214
12131215 /* other utilities */
12141216 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); · 3 unmodified lines
12181220 ST_FUNC void cstr_wccat(CString *cstr, int ch);
12191221 ST_FUNC void cstr_new(CString *cstr);
12201222 ST_FUNC void cstr_free(CString *cstr);
1221−ST_FUNC int cstr_printf(CString *cs, const char *fmt, ...);
1223+ST_FUNC int cstr_printf(CString *cs, const char *fmt, ...) PRINTF_LIKE(2,3);
12221224 ST_FUNC void cstr_reset(CString *cstr);
12231225
12241226 ST_INLN void sym_free(Sym *sym);
tccasm.c+1−1
@@ -108,7 +108,7 @@ static void asm_expr_unary(TCCState *s1, ExprValue *pe) · 107 unmodified lines
108108 if (sym && (!sym->c || elfsym(sym)->st_shndx == SHN_UNDEF))
109109 sym = sym->prev_tok;
110110 if (!sym)
111− tcc_error("local label '%d' not found backward", n);
111+ tcc_error("local label '%d' not found backward", (int)n);
112112 } else {
113113 /* forward */
114114 if (!sym || (sym->c && elfsym(sym)->st_shndx != SHN_UNDEF)) {
tccelf.c+1−1
@@ -2808,7 +2808,7 @@ ST_FUNC int tcc_load_object_file(TCCState *s1, · 2807 unmodified lines
28082808 ) {
28092809 invalid_reloc:
28102810 tcc_error_noabort("Invalid relocation entry [%2d] '%s' @ %.8x",
2811− i, strsec + sh->sh_name, rel->r_offset);
2811+ i, strsec + sh->sh_name, (int)rel->r_offset);
28122812 goto fail;
28132813 }
28142814 rel->r_info = ELFW(R_INFO)(sym_index, type);
tccgen.c+3−2
@@ -368,7 +368,8 @@ ST_FUNC void test_lvalue(void) · 367 unmodified lines
368368 ST_FUNC void check_vstack(void)
369369 {
370370 if (vtop != vstack - 1)
371− tcc_error("internal compiler error: vstack leak (%d)", vtop - vstack + 1);
371+ tcc_error("internal compiler error: vstack leak (%d)",
372+ (int)(vtop - vstack + 1));
372373 }
373374
374375 /* ------------------------------------------------------------------------- */
@@ -8071,7 +8072,7 @@ static int decl0(int l, int is_for_loop_init, Sym *func_sym) · 7696 unmodified lines
80718072 skip(',');
80728073 parse_mult_str(&error_str, "string constant");
80738074 if (c == 0)
8074− tcc_error("%s", error_str.data);
8075+ tcc_error("%s", (char *)error_str.data);
80758076 cstr_free(&error_str);
80768077 skip(')');
80778078 static_assert_out:
tccpp.c+1−1
@@ -3150,7 +3150,7 @@ static int paste_tokens(int t1, CValue *v1, int t2, CValue *v2) · 3149 unmodified lines
31503150 if (is_space(tok))
31513151 continue;
31523152 tcc_warning("pasting \"%.*s\" and \"%s\" does not give a valid"
3153− " preprocessing token", n, cstr.data, (char*)cstr.data + n);
3153+ " preprocessing token", n, (char *)cstr.data, (char*)cstr.data + n);
31543154 ret = 0;
31553155 break;
31563156 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t