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
98#ifdef _MSC_VER98#ifdef _MSC_VER
99# define NORETURN __declspec(noreturn)99# define NORETURN __declspec(noreturn)
100# define ALIGNED(x) __declspec(align(x))100# define ALIGNED(x) __declspec(align(x))
101# define PRINTF_LIKE(x,y)
101#else102#else
102# define NORETURN __attribute__((noreturn))103# define NORETURN __attribute__((noreturn))
103# define ALIGNED(x) __attribute__((aligned(x)))104# define ALIGNED(x) __attribute__((aligned(x)))
105# define PRINTF_LIKE(x,y) __attribute__ ((format (printf, (x), (y))))
104#endif106#endif
105 107
106/* gnu headers use to #define __attribute__ to empty for non-gcc compilers */108/* 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
1206#define realloc(p, s) use_tcc_realloc(p, s)1208#define realloc(p, s) use_tcc_realloc(p, s)
1207#undef strdup1209#undef strdup
1208#define strdup(s) use_tcc_strdup(s)1210#define strdup(s) use_tcc_strdup(s)
1209PUB_FUNC void _tcc_error_noabort(const char *fmt, ...);1211PUB_FUNC void _tcc_error_noabort(const char *fmt, ...) PRINTF_LIKE(1,2);
1210PUB_FUNC NORETURN void _tcc_error(const char *fmt, ...);1212PUB_FUNC NORETURN void _tcc_error(const char *fmt, ...) PRINTF_LIKE(1,2);
1211PUB_FUNC void _tcc_warning(const char *fmt, ...);1213PUB_FUNC void _tcc_warning(const char *fmt, ...) PRINTF_LIKE(1,2);
1212 1214
1213/* other utilities */1215/* other utilities */
1214ST_FUNC void dynarray_add(void *ptab, int *nb_ptr, void *data);1216ST_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
1218ST_FUNC void cstr_wccat(CString *cstr, int ch);1220ST_FUNC void cstr_wccat(CString *cstr, int ch);
1219ST_FUNC void cstr_new(CString *cstr);1221ST_FUNC void cstr_new(CString *cstr);
1220ST_FUNC void cstr_free(CString *cstr);1222ST_FUNC void cstr_free(CString *cstr);
1221ST_FUNC int cstr_printf(CString *cs, const char *fmt, ...);1223ST_FUNC int cstr_printf(CString *cs, const char *fmt, ...) PRINTF_LIKE(2,3);
1222ST_FUNC void cstr_reset(CString *cstr);1224ST_FUNC void cstr_reset(CString *cstr);
1223 1225
1224ST_INLN void sym_free(Sym *sym);1226ST_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
108 if (sym && (!sym->c || elfsym(sym)->st_shndx == SHN_UNDEF))108 if (sym && (!sym->c || elfsym(sym)->st_shndx == SHN_UNDEF))
109 sym = sym->prev_tok;109 sym = sym->prev_tok;
110 if (!sym)110 if (!sym)
111 tcc_error("local label '%d' not found backward", n);111 tcc_error("local label '%d' not found backward", (int)n);
112 } else {112 } else {
113 /* forward */113 /* forward */
114 if (!sym || (sym->c && elfsym(sym)->st_shndx != SHN_UNDEF)) {114 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
2808 ) {2808 ) {
2809 invalid_reloc:2809 invalid_reloc:
2810 tcc_error_noabort("Invalid relocation entry [%2d] '%s' @ %.8x",2810 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);
2812 goto fail;2812 goto fail;
2813 }2813 }
2814 rel->r_info = ELFW(R_INFO)(sym_index, type);2814 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
368ST_FUNC void check_vstack(void)368ST_FUNC void check_vstack(void)
369{369{
370 if (vtop != vstack - 1)370 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));
372}373}
373 374
374/* ------------------------------------------------------------------------- */375/* ------------------------------------------------------------------------- */
@@ -8071,7 +8072,7 @@ static int decl0(int l, int is_for_loop_init, Sym *func_sym) · 7696 unmodified lines
8071 skip(',');8072 skip(',');
8072 parse_mult_str(&error_str, "string constant");8073 parse_mult_str(&error_str, "string constant");
8073 if (c == 0)8074 if (c == 0)
8074 tcc_error("%s", error_str.data);8075 tcc_error("%s", (char *)error_str.data);
8075 cstr_free(&error_str);8076 cstr_free(&error_str);
8076 skip(')');8077 skip(')');
8077 static_assert_out:8078 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
3150 if (is_space(tok))3150 if (is_space(tok))
3151 continue;3151 continue;
3152 tcc_warning("pasting \"%.*s\" and \"%s\" does not give a valid"3152 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);
3154 ret = 0;3154 ret = 0;
3155 break;3155 break;
3156 }3156 }

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