rename error/warning -> tcc_(error/warning)

master
grischka 2011-08-11 17:07:56 +02:00
parent 74a24d77fd
commit bf374a5f23
15 changed files with 275 additions and 285 deletions

View File

@ -195,7 +195,7 @@ void o(uint32_t i)
ind1 = ind + 4;
if (!cur_text_section)
error("compiler error! This happens f.ex. if the compiler\n"
tcc_error("compiler error! This happens f.ex. if the compiler\n"
"can't evaluate constant expressions outside of a function.");
if (ind1 > cur_text_section->data_allocated)
section_realloc(cur_text_section, ind1);
@ -324,7 +324,7 @@ ST_FUNC uint32_t encbranch(int pos, int addr, int fail)
addr/=4;
if(addr>=0x1000000 || addr<-0x1000000) {
if(fail)
error("FIXME: function bigger than 32MB");
tcc_error("FIXME: function bigger than 32MB");
return 0;
}
return 0x0A000000|(addr&0xffffff);
@ -366,14 +366,14 @@ void gsym(int t)
static uint32_t vfpr(int r)
{
if(r<TREG_F0 || r>TREG_F7)
error("compiler error! register %i is no vfp register",r);
tcc_error("compiler error! register %i is no vfp register",r);
return r-5;
}
#else
static uint32_t fpr(int r)
{
if(r<TREG_F0 || r>TREG_F3)
error("compiler error! register %i is no fpa register",r);
tcc_error("compiler error! register %i is no fpa register",r);
return r-5;
}
#endif
@ -383,7 +383,7 @@ static uint32_t intr(int r)
if(r==4)
return 12;
if((r<0 || r>4) && r!=14)
error("compiler error! register %i is no int register",r);
tcc_error("compiler error! register %i is no int register",r);
return r;
}
@ -443,7 +443,7 @@ static uint32_t mapcc(int cc)
case TOK_GT:
return 0xC0000000; /* GT */
}
error("unexpected condition code");
tcc_error("unexpected condition code");
return 0xE0000000; /* AL */
}
@ -476,7 +476,7 @@ static int negcc(int cc)
case TOK_GT:
return TOK_LE;
}
error("unexpected condition code");
tcc_error("unexpected condition code");
return TOK_NE;
}
@ -616,7 +616,7 @@ void load(int r, SValue *sv)
return;
}
}
error("load unimplemented!");
tcc_error("load unimplemented!");
}
/* store register 'r' in lvalue 'v' */
@ -697,7 +697,7 @@ void store(int r, SValue *sv)
return;
}
}
error("store unimplemented");
tcc_error("store unimplemented");
}
static void gadd_sp(int val)
@ -1271,7 +1271,7 @@ done:
vtop->r = retreg;
break;
default:
error("gen_opi %i unimplemented!",op);
tcc_error("gen_opi %i unimplemented!",op);
}
}
@ -1325,7 +1325,7 @@ void gen_opf(int op)
break;
default:
if(op < TOK_ULT && op > TOK_GT) {
error("unknown fp op %x!",op);
tcc_error("unknown fp op %x!",op);
return;
}
if(is_zero(-1)) {
@ -1520,7 +1520,7 @@ void gen_opf(int op)
case TOK_UGE:
case TOK_ULE:
case TOK_UGT:
error("unsigned comparision on floats?");
tcc_error("unsigned comparision on floats?");
break;
case TOK_LT:
op=TOK_Nset;
@ -1564,7 +1564,7 @@ void gen_opf(int op)
vtop[-1].r = VT_CMP;
vtop[-1].c.i = op;
} else {
error("unknown fp op %x!",op);
tcc_error("unknown fp op %x!",op);
return;
}
}
@ -1661,7 +1661,7 @@ ST_FUNC void gen_cvt_itof1(int t)
return;
}
}
error("unimplemented gen_cvt_itof %x!",vtop->type.t);
tcc_error("unimplemented gen_cvt_itof %x!",vtop->type.t);
}
/* convert fp to int 't' type */
@ -1721,7 +1721,7 @@ void gen_cvt_ftoi(int t)
vtop->r = REG_IRET;
return;
}
error("unimplemented gen_cvt_ftoi!");
tcc_error("unimplemented gen_cvt_ftoi!");
}
/* convert from one floating point type to another */

View File

@ -95,7 +95,7 @@ enum {
#define ALWAYS_ASSERT(x) \
do {\
if (!(x))\
error("internal compiler error file at %s:%d", __FILE__, __LINE__);\
tcc_error("internal compiler error file at %s:%d", __FILE__, __LINE__);\
} while (0)
/* defined if function parameters must be evaluated in reverse order */
@ -1572,7 +1572,7 @@ void load(int r, SValue * sv)
load(r, &v1);
fr = r;
} else if ((ft & VT_BTYPE) == VT_LDOUBLE) {
error("long double not supported");
tcc_error("long double not supported");
} else if ((ft & VT_TYPE) == VT_BYTE) {
size = 1;
} else if ((ft & VT_TYPE) == (VT_BYTE | VT_UNSIGNED)) {
@ -1726,7 +1726,7 @@ void store(int r, SValue * v)
/* XXX: incorrect if float reg to reg */
if (bt == VT_LDOUBLE) {
error("long double not supported");
tcc_error("long double not supported");
} else {
if (bt == VT_SHORT)
size = 2;
@ -1881,7 +1881,7 @@ void gfunc_call(int nb_args)
int args_sizes[NoCallArgsPassedOnStack];
if (nb_args > NoCallArgsPassedOnStack) {
error("more than 10 function params not currently supported");
tcc_error("more than 10 function params not currently supported");
// handle more than 10, put some on the stack
}
@ -1896,9 +1896,9 @@ void gfunc_call(int nb_args)
if ((vtop->type.t & VT_BTYPE) == VT_LLONG) {
error("long long not supported");
tcc_error("long long not supported");
} else if ((vtop->type.t & VT_BTYPE) == VT_LDOUBLE) {
error("long double not supported");
tcc_error("long double not supported");
} else if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE) {
size = 8;
} else {
@ -2329,7 +2329,7 @@ void gen_opf(int op)
if ((ft & VT_BTYPE) == VT_LDOUBLE)
error("long doubles not supported");
tcc_error("long doubles not supported");
if (op >= TOK_ULT && op <= TOK_GT) {
@ -2481,7 +2481,7 @@ void gen_cvt_ftoi(int t)
r = vtop->r;
if (t != VT_INT)
error("long long not supported");
tcc_error("long long not supported");
else {
if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE) {
C67_DPTRUNC(r, r);

View File

@ -243,7 +243,7 @@ static inline int get_reg_shift(TCCState *s1)
int shift, v;
#ifdef I386_ASM_16
if (s1->seg_size == 16)
error("invalid effective address");
tcc_error("invalid effective address");
#endif
v = asm_int_expr(s1);
switch(v) {
@ -342,7 +342,7 @@ static void parse_operand(TCCState *s1, Operand *op)
goto no_skip;
} else {
reg_error:
error("unknown register");
tcc_error("unknown register");
}
next();
no_skip: ;
@ -551,12 +551,12 @@ static inline void asm_modrm(int reg, Operand *op)
} else if ((sib_reg1 == 3) && (reg2 == 7)) {
reg1 = 1;
} else {
error("invalid effective address");
tcc_error("invalid effective address");
}
if (op->e.v == 0)
mod = 0;
} else {
error("invalid register");
tcc_error("invalid register");
}
g(mod + (reg << 3) + reg1);
}
@ -599,18 +599,18 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode)
if (tok == ';' || tok == TOK_LINEFEED)
break;
if (nb_ops >= MAX_OPERANDS) {
error("incorrect number of operands");
tcc_error("incorrect number of operands");
}
parse_operand(s1, pop);
if (tok == ':') {
if (pop->type != OP_SEG || seg_prefix)
error("incorrect prefix");
tcc_error("incorrect prefix");
seg_prefix = segment_prefixes[pop->reg];
next();
parse_operand(s1, pop);
#ifndef I386_ASM_16
if (!(pop->type & OP_EA)) {
error("segment prefix must be followed by memory reference");
tcc_error("segment prefix must be followed by memory reference");
}
#endif
}
@ -701,12 +701,12 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode)
#ifdef I386_ASM_16
if (opcode == TOK_ASM_o32) {
if (s1->seg_size == 32)
error("incorrect prefix");
tcc_error("incorrect prefix");
else
o32 = data32 = 1;
} else if (opcode == TOK_ASM_a32) {
if (s1->seg_size == 32)
error("incorrect prefix");
tcc_error("incorrect prefix");
else
a32 = addr32 = 1;
}
@ -716,7 +716,7 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode)
g(b);
return;
} else {
error("unknown opcode '%s'",
tcc_error("unknown opcode '%s'",
get_tok_str(opcode, NULL));
}
}
@ -731,7 +731,7 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode)
(ops[0].type & (OP_SEG | OP_IM8S | OP_IM32 | OP_IM64)))
s = 2;
else
error("cannot infer opcode suffix");
tcc_error("cannot infer opcode suffix");
}
}
@ -849,7 +849,7 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode)
else
v += 0x0f10;
} else {
error("invalid displacement");
tcc_error("invalid displacement");
}
}
}
@ -883,7 +883,7 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode)
goto modrm_found;
}
#ifdef ASM_DEBUG
error("bad op table");
tcc_error("bad op table");
#endif
modrm_found:
modrm_index = i;
@ -912,7 +912,7 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode)
#endif
gen_expr32(&ops[1].e);
if (ops[0].e.sym)
error("cannot relocate");
tcc_error("cannot relocate");
gen_le16(ops[0].e.v);
return;
}
@ -944,7 +944,7 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode)
#endif
if (ops[i].e.sym)
error_relocate:
error("cannot relocate");
tcc_error("cannot relocate");
else
gen_le16(ops[i].e.v);
} else {
@ -1032,7 +1032,7 @@ static inline int constraint_priority(const char *str)
pr = 4;
break;
default:
error("unknown constraint '%c'", c);
tcc_error("unknown constraint '%c'", c);
pr = 0;
}
if (pr > priority)
@ -1083,11 +1083,11 @@ ST_FUNC void asm_compute_constraints(ASMOperand *operands,
/* this is a reference to another constraint */
k = find_constraint(operands, nb_operands, str, NULL);
if ((unsigned)k >= i || i < nb_outputs)
error("invalid reference in constraint %d ('%s')",
tcc_error("invalid reference in constraint %d ('%s')",
i, str);
op->ref_index = k;
if (operands[k].input_index >= 0)
error("cannot reference twice the same operand");
tcc_error("cannot reference twice the same operand");
operands[k].input_index = i;
op->priority = 5;
} else {
@ -1147,7 +1147,7 @@ ST_FUNC void asm_compute_constraints(ASMOperand *operands,
/* FALL THRU */
case '&':
if (j >= nb_outputs)
error("'%c' modifier can only be applied to outputs", c);
tcc_error("'%c' modifier can only be applied to outputs", c);
reg_mask = REG_IN_MASK | REG_OUT_MASK;
goto try_next;
case 'A':
@ -1238,7 +1238,7 @@ ST_FUNC void asm_compute_constraints(ASMOperand *operands,
}
break;
default:
error("asm constraint %d ('%s') could not be satisfied",
tcc_error("asm constraint %d ('%s') could not be satisfied",
j, op->constraint);
break;
}
@ -1261,7 +1261,7 @@ ST_FUNC void asm_compute_constraints(ASMOperand *operands,
if (!(regs_allocated[reg] & REG_OUT_MASK))
goto reg_found2;
}
error("could not find free output register for reloading");
tcc_error("could not find free output register for reloading");
reg_found2:
*pout_reg = reg;
break;
@ -1314,7 +1314,7 @@ ST_FUNC void subst_asm_operand(CString *add_str,
} else if (r & VT_LVAL) {
reg = r & VT_VALMASK;
if (reg >= VT_CONST)
error("internal compiler error");
tcc_error("internal compiler error");
snprintf(buf, sizeof(buf), "(%%%s)",
get_tok_str(TOK_ASM_eax + reg, NULL));
cstr_cat(add_str, buf);
@ -1322,7 +1322,7 @@ ST_FUNC void subst_asm_operand(CString *add_str,
/* register case */
reg = r & VT_VALMASK;
if (reg >= VT_CONST)
error("internal compiler error");
tcc_error("internal compiler error");
/* choose register operand size */
if ((sv->type.t & VT_BTYPE) == VT_BYTE)
@ -1340,11 +1340,11 @@ ST_FUNC void subst_asm_operand(CString *add_str,
if (modifier == 'b') {
if (reg >= 4)
error("cannot use byte register");
tcc_error("cannot use byte register");
size = 1;
} else if (modifier == 'h') {
if (reg >= 4)
error("cannot use byte register");
tcc_error("cannot use byte register");
size = -1;
} else if (modifier == 'w') {
size = 2;
@ -1492,7 +1492,7 @@ ST_FUNC void asm_clobber(uint8_t *clobber_regs, const char *str)
reg -= TOK_ASM_rax;
#endif
} else {
error("invalid clobber register '%s'", str);
tcc_error("invalid clobber register '%s'", str);
}
clobber_regs[reg] = 1;
}

View File

@ -1068,7 +1068,7 @@ ST_FUNC void gen_bounded_ptr_deref(void)
case 12: func = TOK___bound_ptr_indir12; break;
case 16: func = TOK___bound_ptr_indir16; break;
default:
error("unhandled size when derefencing bounded pointer");
tcc_error("unhandled size when derefencing bounded pointer");
func = 0;
break;
}

View File

@ -193,7 +193,7 @@ static void il_type_to_str(char *buf, int buf_size,
pstrcat(buf, buf_size, tstr);
break;
case VT_STRUCT:
error("structures not handled yet");
tcc_error("structures not handled yet");
break;
case VT_FUNC:
s = sym_find((unsigned)t >> VT_STRUCT_SHIFT);
@ -387,7 +387,7 @@ void gfunc_start(GFuncContext *c, int func_call)
void gfunc_param(GFuncContext *c)
{
if ((vtop->t & VT_BTYPE) == VT_STRUCT) {
error("structures passed as value not handled yet");
tcc_error("structures passed as value not handled yet");
} else {
/* simply push on stack */
gv(RC_ST0);

View File

@ -69,11 +69,11 @@ ST_DATA struct TCCState *tcc_state;
#ifndef CONFIG_TCC_ASM
ST_FUNC void asm_instr(void)
{
error("inline asm() not supported");
tcc_error("inline asm() not supported");
}
ST_FUNC void asm_global_instr(void)
{
error("inline asm() not supported");
tcc_error("inline asm() not supported");
}
#endif
@ -213,7 +213,7 @@ PUB_FUNC void *tcc_malloc(unsigned long size)
void *ptr;
ptr = malloc(size);
if (!ptr && size)
error("memory full");
tcc_error("memory full");
#ifdef MEM_DEBUG
mem_cur_size += malloc_usable_size(ptr);
if (mem_cur_size > mem_max_size)
@ -283,7 +283,7 @@ PUB_FUNC void dynarray_add(void ***ptab, int *nb_ptr, void *data)
nb_alloc = nb * 2;
pp = tcc_realloc(pp, nb_alloc * sizeof(void *));
if (!pp)
error("memory full");
tcc_error("memory full");
*ptab = pp;
}
pp[nb++] = data;
@ -378,7 +378,7 @@ ST_FUNC void section_realloc(Section *sec, unsigned long new_size)
size = size * 2;
data = tcc_realloc(sec->data, size);
if (!data)
error("memory full");
tcc_error("memory full");
memset(data + sec->data_allocated, 0, size - sec->data_allocated);
sec->data = data;
sec->data_allocated = size;
@ -609,7 +609,7 @@ LIBTCCAPI void tcc_set_error_func(TCCState *s, void *error_opaque,
}
/* error without aborting current compilation */
PUB_FUNC void error_noabort(const char *fmt, ...)
PUB_FUNC void tcc_error_noabort(const char *fmt, ...)
{
TCCState *s1 = tcc_state;
va_list ap;
@ -619,7 +619,7 @@ PUB_FUNC void error_noabort(const char *fmt, ...)
va_end(ap);
}
PUB_FUNC void error(const char *fmt, ...)
PUB_FUNC void tcc_error(const char *fmt, ...)
{
TCCState *s1 = tcc_state;
va_list ap;
@ -636,7 +636,7 @@ PUB_FUNC void error(const char *fmt, ...)
}
}
PUB_FUNC void warning(const char *fmt, ...)
PUB_FUNC void tcc_warning(const char *fmt, ...)
{
TCCState *s1 = tcc_state;
va_list ap;
@ -790,7 +790,7 @@ static int tcc_compile(TCCState *s1)
if (tok != TOK_EOF)
expect("declaration");
if (pvtop != vtop)
warning("internal compiler error: vstack leak? (%d)", vtop - pvtop);
tcc_warning("internal compiler error: vstack leak? (%d)", vtop - pvtop);
/* end of translation unit info */
if (s1->do_debug) {
@ -1105,7 +1105,7 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags)
ret = tcc_open(s1, filename);
if (ret < 0) {
if (flags & AFF_PRINT_ERROR)
error_noabort("file '%s' not found", filename);
tcc_error_noabort("file '%s' not found", filename);
return ret;
}
@ -1143,7 +1143,7 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags)
size = read(fd, &ehdr, sizeof(ehdr));
lseek(fd, 0, SEEK_SET);
if (size <= 0) {
error_noabort("could not read header");
tcc_error_noabort("could not read header");
goto the_end;
}
@ -1174,7 +1174,7 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags)
goto the_end;
}
#endif
error_noabort("unrecognized ELF file");
tcc_error_noabort("unrecognized ELF file");
goto the_end;
}
@ -1198,7 +1198,7 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags)
ret = tcc_load_ldscript(s1);
#endif
if (ret < 0)
error_noabort("unrecognized file type");
tcc_error_noabort("unrecognized file type");
the_end:
tcc_close();
@ -1247,7 +1247,7 @@ ST_FUNC int tcc_add_crt(TCCState *s, const char *filename)
{
if (-1 == tcc_add_library_internal(s, "%s/%s",
filename, 0, s->crt_paths, s->nb_crt_paths))
error_noabort("file '%s' not found", filename);
tcc_error_noabort("file '%s' not found", filename);
return 0;
}
@ -1485,14 +1485,14 @@ PUB_FUNC const char * tcc_set_linker(TCCState *s, char *option, int multi)
} else if (link_option(option, "fini=", &p)) {
s->fini_symbol = p;
if (s->warn_unsupported)
warning("ignoring -fini %s", p);
tcc_warning("ignoring -fini %s", p);
} else if (link_option(option, "image-base=", &p)) {
s->text_addr = strtoul(p, &end, 16);
s->has_text_addr = 1;
} else if (link_option(option, "init=", &p)) {
s->init_symbol = p;
if (s->warn_unsupported)
warning("ignoring -init %s", p);
tcc_warning("ignoring -init %s", p);
} else if (link_option(option, "oformat=", &p)) {
#if defined(TCC_TARGET_PE)
if (strstart(p, "pe-", NULL)) {
@ -1647,7 +1647,7 @@ PUB_FUNC void tcc_gen_makedeps(TCCState *s, const char *target, const char *file
/* XXX return err codes instead of error() ? */
depout = fopen(filename, "w");
if (!depout)
error("could not open '%s'", filename);
tcc_error("could not open '%s'", filename);
fprintf(depout, "%s : \\\n", target);
for (i=0; i<s->nb_target_deps; ++i)

22
tcc.c
View File

@ -254,11 +254,11 @@ static void exec_other_tcc(TCCState *s, char **argv, const char *optarg)
printf("tcc: using '%s'\n", child_name), fflush(stdout);
execvp(argv[0] = child_path, argv);
}
error("'%s' not found", child_name);
tcc_error("'%s' not found", child_name);
case 0: /* ignore -march etc. */
break;
default:
warning("unsupported option \"-m%s\"", optarg);
tcc_warning("unsupported option \"-m%s\"", optarg);
}
}
#endif
@ -301,7 +301,7 @@ static int parse_args(TCCState *s, int argc, char **argv)
for(;;) {
p1 = popt->name;
if (p1 == NULL)
error("invalid option -- '%s'", r);
tcc_error("invalid option -- '%s'", r);
r1 = r + 1;
for(;;) {
if (*p1 == '\0')
@ -319,7 +319,7 @@ static int parse_args(TCCState *s, int argc, char **argv)
optarg = r1;
} else {
if (optind >= argc)
error("argument to '%s' is missing", r);
tcc_error("argument to '%s' is missing", r);
optarg = argv[optind++];
}
} else {
@ -334,7 +334,7 @@ static int parse_args(TCCState *s, int argc, char **argv)
case TCC_OPTION_I:
if (tcc_add_include_path(s, optarg) < 0)
error("too many include paths");
tcc_error("too many include paths");
break;
case TCC_OPTION_D:
parse_option_D(s, optarg);
@ -443,7 +443,7 @@ static int parse_args(TCCState *s, int argc, char **argv)
break;
case TCC_OPTION_Wl:
if ((r = (char *) tcc_set_linker(s, (char *)optarg, TRUE)))
error("unsupported linker option '%s'", r);
tcc_error("unsupported linker option '%s'", r);
break;
case TCC_OPTION_E:
output_type = TCC_OUTPUT_PREPROCESS;
@ -459,7 +459,7 @@ static int parse_args(TCCState *s, int argc, char **argv)
default:
if (s->warn_unsupported) {
unsupported_option:
warning("unsupported option '%s'", r);
tcc_warning("unsupported option '%s'", r);
}
break;
}
@ -528,9 +528,9 @@ int main(int argc, char **argv)
if (output_type == TCC_OUTPUT_OBJ && !reloc_output) {
/* accepts only a single input file */
if (nb_objfiles != 1)
error("cannot specify multiple files with -c");
tcc_error("cannot specify multiple files with -c");
if (nb_libraries != 0)
error("cannot specify libraries with -c");
tcc_error("cannot specify libraries with -c");
}
if (output_type == TCC_OUTPUT_PREPROCESS) {
@ -539,7 +539,7 @@ int main(int argc, char **argv)
} else {
s->outfile = fopen(outfile, "w");
if (!s->outfile)
error("could not open '%s'", outfile);
tcc_error("could not open '%s'", outfile);
}
}
@ -557,7 +557,7 @@ int main(int argc, char **argv)
filename = files[i];
if (filename[0] == '-' && filename[1] == 'l') {
if (tcc_add_library(s, filename + 2) < 0) {
error_noabort("cannot find %s", filename);
tcc_error_noabort("cannot find %s", filename);
ret = 1;
}
} else {

6
tcc.h
View File

@ -985,9 +985,9 @@ PUB_FUNC char *tcc_strdup(const char *str);
PUB_FUNC void tcc_memstats(void);
PUB_FUNC void dynarray_add(void ***ptab, int *nb_ptr, void *data);
PUB_FUNC void dynarray_reset(void *pp, int *n);
PUB_FUNC void error_noabort(const char *fmt, ...);
PUB_FUNC void error(const char *fmt, ...);
PUB_FUNC void warning(const char *fmt, ...);
PUB_FUNC void tcc_error_noabort(const char *fmt, ...);
PUB_FUNC void tcc_error(const char *fmt, ...);
PUB_FUNC void tcc_warning(const char *fmt, ...);
/* other utilities */
ST_INLN void cstr_ccat(CString *cstr, int ch);

View File

@ -54,7 +54,7 @@ static void asm_expr_unary(TCCState *s1, ExprValue *pe)
if (sym && sym->r == 0)
sym = sym->prev_tok;
if (!sym)
error("local label '%d' not found backward", n);
tcc_error("local label '%d' not found backward", n);
} else {
/* forward */
if (!sym || sym->r) {
@ -69,7 +69,7 @@ static void asm_expr_unary(TCCState *s1, ExprValue *pe)
pe->v = n;
pe->sym = NULL;
} else {
error("invalid number syntax");
tcc_error("invalid number syntax");
}
next();
break;
@ -83,7 +83,7 @@ static void asm_expr_unary(TCCState *s1, ExprValue *pe)
next();
asm_expr_unary(s1, pe);
if (pe->sym)
error("invalid operation with label");
tcc_error("invalid operation with label");
if (op == '-')
pe->v = -pe->v;
else
@ -119,7 +119,7 @@ static void asm_expr_unary(TCCState *s1, ExprValue *pe)
}
next();
} else {
error("bad expression syntax [%s]", get_tok_str(tok, &tokc));
tcc_error("bad expression syntax [%s]", get_tok_str(tok, &tokc));
}
break;
}
@ -139,7 +139,7 @@ static void asm_expr_prod(TCCState *s1, ExprValue *pe)
next();
asm_expr_unary(s1, &e2);
if (pe->sym || e2.sym)
error("invalid operation with label");
tcc_error("invalid operation with label");
switch(op) {
case '*':
pe->v *= e2.v;
@ -147,7 +147,7 @@ static void asm_expr_prod(TCCState *s1, ExprValue *pe)
case '/':
if (e2.v == 0) {
div_error:
error("division by zero");
tcc_error("division by zero");
}
pe->v /= e2.v;
break;
@ -180,7 +180,7 @@ static void asm_expr_logic(TCCState *s1, ExprValue *pe)
next();
asm_expr_prod(s1, &e2);
if (pe->sym || e2.sym)
error("invalid operation with label");
tcc_error("invalid operation with label");
switch(op) {
case '&':
pe->v &= e2.v;
@ -234,7 +234,7 @@ static inline void asm_expr_sum(TCCState *s1, ExprValue *pe)
pe->sym = NULL; /* same symbols can be substracted to NULL */
} else {
cannot_relocate:
error("invalid operation with label");
tcc_error("invalid operation with label");
}
}
}
@ -266,7 +266,7 @@ static void asm_new_label1(TCCState *s1, int label, int is_local,
if (sym->r) {
/* the label is already defined */
if (!is_local) {
error("assembler label '%s' already defined",
tcc_error("assembler label '%s' already defined",
get_tok_str(label, NULL));
} else {
/* redefinition of local labels is possible */
@ -341,7 +341,7 @@ static void asm_parse_directive(TCCState *s1)
n = asm_int_expr(s1);
if (tok1 == TOK_ASM_align) {
if (n < 0 || (n & (n-1)) != 0)
error("alignment must be a positive power of two");
tcc_error("alignment must be a positive power of two");
offset = (ind + n - 1) & -n;
size = offset - ind;
/* the section must have a compatible alignment */
@ -372,7 +372,7 @@ static void asm_parse_directive(TCCState *s1)
p = tokc.cstr->data;
if (tok != TOK_PPNUM) {
error_constant:
error("64 bit constant");
tcc_error("64 bit constant");
}
vl = strtoll(p, (char **)&p, 0);
if (*p != '\0')
@ -431,7 +431,7 @@ static void asm_parse_directive(TCCState *s1)
next();
repeat = asm_int_expr(s1);
if (repeat < 0) {
error("repeat < 0; .fill ignored");
tcc_error("repeat < 0; .fill ignored");
break;
}
size = 1;
@ -440,7 +440,7 @@ static void asm_parse_directive(TCCState *s1)
next();
size = asm_int_expr(s1);
if (size < 0) {
error("size < 0; .fill ignored");
tcc_error("size < 0; .fill ignored");
break;
}
if (size > 8)
@ -473,7 +473,7 @@ static void asm_parse_directive(TCCState *s1)
/* XXX: handle section symbols too */
n = asm_int_expr(s1);
if (n < ind)
error("attempt to .org backwards");
tcc_error("attempt to .org backwards");
v = 0;
size = n - ind;
goto zero_pad;
@ -554,7 +554,7 @@ static void asm_parse_directive(TCCState *s1)
pstrcat(filename, sizeof(filename), get_tok_str(tok, NULL));
if (s1->warn_unsupported)
warning("ignoring .file %s", filename);
tcc_warning("ignoring .file %s", filename);
next();
}
@ -572,7 +572,7 @@ static void asm_parse_directive(TCCState *s1)
pstrcat(ident, sizeof(ident), get_tok_str(tok, NULL));
if (s1->warn_unsupported)
warning("ignoring .ident %s", ident);
tcc_warning("ignoring .ident %s", ident);
next();
}
@ -584,14 +584,14 @@ static void asm_parse_directive(TCCState *s1)
next();
sym = label_find(tok);
if (!sym) {
error("label not found: %s", get_tok_str(tok, NULL));
tcc_error("label not found: %s", get_tok_str(tok, NULL));
}
next();
skip(',');
/* XXX .size name,label2-label1 */
if (s1->warn_unsupported)
warning("ignoring .size %s,*", get_tok_str(tok, NULL));
tcc_warning("ignoring .size %s,*", get_tok_str(tok, NULL));
while (tok != '\n' && tok != CH_EOF) {
next();
@ -624,7 +624,7 @@ static void asm_parse_directive(TCCState *s1)
sym->type.t = VT_FUNC;
}
else if (s1->warn_unsupported)
warning("change type of '%s' from 0x%x to '%s' ignored",
tcc_warning("change type of '%s' from 0x%x to '%s' ignored",
get_tok_str(sym->v, NULL), sym->type.t, newtype);
next();
@ -660,7 +660,7 @@ static void asm_parse_directive(TCCState *s1)
Section *sec;
next();
if (!last_text_section)
error("no previous section referenced");
tcc_error("no previous section referenced");
sec = cur_text_section;
use_section1(s1, last_text_section);
last_text_section = sec;
@ -687,7 +687,7 @@ static void asm_parse_directive(TCCState *s1)
break;
#endif
default:
error("unknown assembler directive '.%s'", get_tok_str(tok, NULL));
tcc_error("unknown assembler directive '.%s'", get_tok_str(tok, NULL));
break;
}
}
@ -913,7 +913,7 @@ static void subst_asm_operands(ASMOperand *operands, int nb_operands,
modifier = *str++;
index = find_constraint(operands, nb_operands, str, &str);
if (index < 0)
error("invalid operand reference after %%");
tcc_error("invalid operand reference after %%");
op = &operands[index];
sv = *op->vt;
if (op->reg >= 0) {
@ -942,7 +942,7 @@ static void parse_asm_operands(ASMOperand *operands, int *nb_operands_ptr,
nb_operands = *nb_operands_ptr;
for(;;) {
if (nb_operands >= MAX_ASM_OPERANDS)
error("too many asm operands");
tcc_error("too many asm operands");
op = &operands[nb_operands++];
op->id = 0;
if (tok == '[') {

View File

@ -533,7 +533,7 @@ ST_FUNC int tcc_output_coff(TCCState *s1, FILE *f)
} else {
if (pCoff_str_table - Coff_str_table + strlen(name) >
MAX_STR_TABLE - 1)
error("String table too large");
tcc_error("String table too large");
csym._n._n_n._n_zeroes = 0;
csym._n._n_n._n_offset =
@ -563,11 +563,7 @@ ST_FUNC int tcc_output_coff(TCCState *s1, FILE *f)
}
if (k >= nFuncs) {
char s[256];
sprintf(s, "debug info can't find function: %s", name);
error(s);
tcc_error("debug info can't find function: %s", name);
}
// put a Function Name
@ -734,13 +730,7 @@ void SortSymbolTable(void)
}
if (k >= nFuncs) {
char s[256];
sprintf(s,
"debug (sort) info can't find function: %s",
name2);
error(s);
tcc_error("debug (sort) info can't find function: %s", name2);
}
if (strcmp(AssociatedFile[k], name) == 0) {
@ -767,7 +757,7 @@ void SortSymbolTable(void)
}
if (n != nb_syms)
error("Internal Compiler error, debug info");
tcc_error("Internal Compiler error, debug info");
// copy it all back
@ -864,7 +854,7 @@ Section *FindSection(TCCState * s1, const char *sname)
return s;
}
error("could not find section %s", sname);
tcc_error("could not find section %s", sname);
return 0;
}
@ -882,39 +872,39 @@ ST_FUNC int tcc_load_coff(TCCState * s1, int fd)
f = fdopen(fd, "rb");
if (!f) {
error("Unable to open .out file for input");
tcc_error("Unable to open .out file for input");
}
if (fread(&file_hdr, FILHSZ, 1, f) != 1)
error("error reading .out file for input");
tcc_error("error reading .out file for input");
if (fread(&o_filehdr, sizeof(o_filehdr), 1, f) != 1)
error("error reading .out file for input");
tcc_error("error reading .out file for input");
// first read the string table
if (fseek(f, file_hdr.f_symptr + file_hdr.f_nsyms * SYMESZ, SEEK_SET))
error("error reading .out file for input");
tcc_error("error reading .out file for input");
if (fread(&str_size, sizeof(int), 1, f) != 1)
error("error reading .out file for input");
tcc_error("error reading .out file for input");
Coff_str_table = (char *) tcc_malloc(str_size);
if (fread(Coff_str_table, str_size - 4, 1, f) != 1)
error("error reading .out file for input");
tcc_error("error reading .out file for input");
// read/process all the symbols
// seek back to symbols
if (fseek(f, file_hdr.f_symptr, SEEK_SET))
error("error reading .out file for input");
tcc_error("error reading .out file for input");
for (i = 0; i < file_hdr.f_nsyms; i++) {
if (fread(&csym, SYMESZ, 1, f) != 1)
error("error reading .out file for input");
tcc_error("error reading .out file for input");
if (csym._n._n_n._n_zeroes == 0) {
name = Coff_str_table + csym._n._n_n._n_offset - 4;
@ -949,7 +939,7 @@ ST_FUNC int tcc_load_coff(TCCState * s1, int fd)
if (csym.n_numaux == 1) {
if (fread(&csym, SYMESZ, 1, f) != 1)
error("error reading .out file for input");
tcc_error("error reading .out file for input");
i++;
}
}

View File

@ -166,7 +166,7 @@ static void *get_elf_sym_addr(TCCState *s, const char *name, int err)
sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
if (!sym_index || sym->st_shndx == SHN_UNDEF) {
if (err)
error("%s not defined", name);
tcc_error("%s not defined", name);
return NULL;
}
return (void*)(uplong)sym->st_value;
@ -242,7 +242,7 @@ ST_FUNC int add_elf_sym(Section *s, uplong value, unsigned long size,
printf("new_bind=%x new_shndx=%x new_vis=%x old_bind=%x old_shndx=%x old_vis=%x\n",
sym_bind, sh_num, new_vis, esym_bind, esym->st_shndx, esym_vis);
#endif
error_noabort("'%s' defined twice", name);
tcc_error_noabort("'%s' defined twice", name);
}
} else {
do_patch:
@ -459,7 +459,7 @@ ST_FUNC void relocate_syms(TCCState *s1, int do_resolve)
if (sym_bind == STB_WEAK) {
sym->st_value = 0;
} else {
error_noabort("undefined symbol '%s'", name);
tcc_error_noabort("undefined symbol '%s'", name);
}
} else if (sh_num < SHN_LORESERVE) {
/* add section base */
@ -586,7 +586,7 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s)
case R_386_16:
if (s1->output_format != TCC_OUTPUT_FORMAT_BINARY) {
output_file:
error("can only produce 16-bit binary files");
tcc_error("can only produce 16-bit binary files");
}
*(short *)ptr += val;
break;
@ -614,7 +614,7 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s)
x += add_jmp_table(s1, val) - val; /* add veneer */
#endif
if((x & 3) != 0 || x >= 0x4000000 || x < -0x4000000)
error("can't relocate value at %x",addr);
tcc_error("can't relocate value at %x",addr);
x >>= 2;
x &= 0xffffff;
(*(int *)ptr) |= x;
@ -628,7 +628,7 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s)
x = (x * 2) / 2;
x += val - addr;
if((x^(x>>1))&0x40000000)
error("can't relocate value at %x",addr);
tcc_error("can't relocate value at %x",addr);
(*(int *)ptr) |= x & 0x7fffffff;
}
case R_ARM_ABS32:
@ -728,7 +728,7 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s)
}
#endif
if (diff <= -2147483647 || diff > 2147483647) {
error("internal error: relocation failed");
tcc_error("internal error: relocation failed");
}
}
*(int *)ptr += diff;
@ -837,7 +837,7 @@ static void put_got_offset(TCCState *s1, int index, unsigned long val)
n *= 2;
tab = tcc_realloc(s1->got_offsets, n * sizeof(unsigned long));
if (!tab)
error("memory full");
tcc_error("memory full");
s1->got_offsets = tab;
memset(s1->got_offsets + s1->nb_got_offsets, 0,
(n - s1->nb_got_offsets) * sizeof(unsigned long));
@ -975,7 +975,7 @@ static void put_got_entry(TCCState *s1,
/* if we build a DLL, we add a %ebx offset */
if (s1->output_type == TCC_OUTPUT_DLL)
error("DLLs unimplemented!");
tcc_error("DLLs unimplemented!");
/* add a PLT entry */
plt = s1->plt;
@ -1000,7 +1000,7 @@ static void put_got_entry(TCCState *s1,
offset = plt->data_offset - 16;
}
#elif defined(TCC_TARGET_C67)
error("C67 got not implemented");
tcc_error("C67 got not implemented");
#else
#error unsupported CPU
#endif
@ -1543,7 +1543,7 @@ static int elf_output_file(TCCState *s1, const char *filename)
if (ELFW(ST_BIND)(sym->st_info) == STB_WEAK ||
!strcmp(name, "_fp_hw")) {
} else {
error_noabort("undefined symbol '%s'", name);
tcc_error_noabort("undefined symbol '%s'", name);
}
}
} else if (s1->rdynamic &&
@ -1581,7 +1581,7 @@ static int elf_output_file(TCCState *s1, const char *filename)
if (ELFW(ST_BIND)(esym->st_info) == STB_WEAK) {
/* weak symbols can stay undefined */
} else {
warning("undefined dynamic symbol '%s'", name);
tcc_warning("undefined dynamic symbol '%s'", name);
}
}
}
@ -2061,7 +2061,7 @@ static int elf_output_file(TCCState *s1, const char *filename)
unlink(filename);
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, mode);
if (fd < 0) {
error_noabort("could not write '%s'", filename);
tcc_error_noabort("could not write '%s'", filename);
goto fail;
}
f = fdopen(fd, "wb");
@ -2244,7 +2244,7 @@ ST_FUNC int tcc_load_object_file(TCCState *s1,
if (ehdr.e_ident[5] != ELFDATA2LSB ||
ehdr.e_machine != EM_TCC_TARGET) {
fail1:
error_noabort("invalid object file");
tcc_error_noabort("invalid object file");
return -1;
}
/* read sections */
@ -2265,7 +2265,7 @@ ST_FUNC int tcc_load_object_file(TCCState *s1,
sh = &shdr[i];
if (sh->sh_type == SHT_SYMTAB) {
if (symtab) {
error_noabort("object must contain only one symtab");
tcc_error_noabort("object must contain only one symtab");
fail:
ret = -1;
goto the_end;
@ -2329,7 +2329,7 @@ ST_FUNC int tcc_load_object_file(TCCState *s1,
sm_table[i].new_section = 1;
found:
if (sh->sh_type != s->sh_type) {
error_noabort("invalid section type");
tcc_error_noabort("invalid section type");
goto fail;
}
@ -2462,7 +2462,7 @@ ST_FUNC int tcc_load_object_file(TCCState *s1,
#endif
) {
invalid_reloc:
error_noabort("Invalid relocation entry [%2d] '%s' @ %.8x",
tcc_error_noabort("Invalid relocation entry [%2d] '%s' @ %.8x",
i, strsec + sh->sh_name, rel->r_offset);
goto fail;
}
@ -2564,7 +2564,7 @@ ST_FUNC int tcc_load_archive(TCCState *s1, int fd)
if (len == 0)
break;
if (len != sizeof(hdr)) {
error_noabort("invalid archive");
tcc_error_noabort("invalid archive");
return -1;
}
memcpy(ar_size, hdr.ar_size, sizeof(hdr.ar_size));
@ -2618,7 +2618,7 @@ ST_FUNC int tcc_load_dll(TCCState *s1, int fd, const char *filename, int level)
/* test CPU specific stuff */
if (ehdr.e_ident[5] != ELFDATA2LSB ||
ehdr.e_machine != EM_TCC_TARGET) {
error_noabort("bad architecture");
tcc_error_noabort("bad architecture");
return -1;
}
@ -2698,7 +2698,7 @@ ST_FUNC int tcc_load_dll(TCCState *s1, int fd, const char *filename, int level)
goto already_loaded;
}
if (tcc_add_dll(s1, name, AFF_REFERENCED_DLL) < 0) {
error_noabort("referenced dll '%s' not found", name);
tcc_error_noabort("referenced dll '%s' not found", name);
ret = -1;
goto the_end;
}
@ -2921,7 +2921,7 @@ static int ld_add_file_list(TCCState *s1, const char *cmd, int as_needed)
for(;;) {
libname[0] = '\0';
if (t == LD_TOK_EOF) {
error_noabort("unexpected end of file");
tcc_error_noabort("unexpected end of file");
ret = -1;
goto lib_parse_error;
} else if (t == ')') {
@ -2929,14 +2929,14 @@ static int ld_add_file_list(TCCState *s1, const char *cmd, int as_needed)
} else if (t == '-') {
t = ld_next(s1, filename, sizeof(filename));
if ((t != LD_TOK_NAME) || (filename[0] != 'l')) {
error_noabort("library name expected");
tcc_error_noabort("library name expected");
ret = -1;
goto lib_parse_error;
}
strcpy(libname, &filename[1]);
libname_to_filename(s1, libname, filename);
} else if (t != LD_TOK_NAME) {
error_noabort("filename expected");
tcc_error_noabort("filename expected");
ret = -1;
goto lib_parse_error;
}
@ -3005,7 +3005,7 @@ ST_FUNC int tcc_load_ldscript(TCCState *s1)
for(;;) {
t = ld_next(s1, filename, sizeof(filename));
if (t == LD_TOK_EOF) {
error_noabort("unexpected end of file");
tcc_error_noabort("unexpected end of file");
return -1;
} else if (t == ')') {
break;

150
tccgen.c
View File

@ -294,7 +294,7 @@ static void vsetc(CType *type, int r, CValue *vc)
int v;
if (vtop >= vstack + (VSTACK_SIZE - 1))
error("memory full");
tcc_error("memory full");
/* cannot let cpu flags if other instruction are generated. Also
avoid leaving VT_JMP anywhere except on the top of the stack
because it would complicate the code generator. */
@ -403,7 +403,7 @@ static Sym *external_sym(int v, CType *type, int r, char *asm_label)
s->r = r | VT_CONST | VT_SYM;
s->type.t |= VT_EXTERN;
} else if (!is_compatible_types(&s->type, type)) {
error("incompatible types for redefinition of '%s'",
tcc_error("incompatible types for redefinition of '%s'",
get_tok_str(v, NULL));
}
return s;
@ -449,7 +449,7 @@ ST_FUNC void vswap(void)
ST_FUNC void vpushv(SValue *v)
{
if (vtop >= vstack + (VSTACK_SIZE - 1))
error("memory full");
tcc_error("memory full");
vtop++;
*vtop = *v;
}
@ -1260,7 +1260,7 @@ static void gen_opl(int op)
b = ind;
o(0x1A000000 | encbranch(ind, 0, 1));
#elif defined(TCC_TARGET_C67)
error("not implemented");
tcc_error("not implemented");
#else
#error not supported
#endif
@ -1333,7 +1333,7 @@ static void gen_opic(int op)
/* if division by zero, generate explicit division */
if (l2 == 0) {
if (const_wanted)
error("division by zero in constant");
tcc_error("division by zero in constant");
goto general_case;
}
switch(op) {
@ -1460,7 +1460,7 @@ static void gen_opif(int op)
case '/':
if (f2 == 0.0) {
if (const_wanted)
error("division by zero in constant");
tcc_error("division by zero in constant");
goto general_case;
}
f1 /= f2;
@ -1530,7 +1530,7 @@ static void check_comparison_pointer_types(SValue *p1, SValue *p2, int op)
/* accept comparison between pointer and integer with a warning */
if ((is_integer_btype(bt1) || is_integer_btype(bt2)) && op != '-') {
if (op != TOK_LOR && op != TOK_LAND )
warning("comparison between pointer and integer");
tcc_warning("comparison between pointer and integer");
return;
}
@ -1544,7 +1544,7 @@ static void check_comparison_pointer_types(SValue *p1, SValue *p2, int op)
type2 = pointed_type(type2);
} else if (bt2 != VT_FUNC) {
invalid_operands:
error("invalid operands to binary %s", get_tok_str(op, NULL));
tcc_error("invalid operands to binary %s", get_tok_str(op, NULL));
}
if ((type1->t & VT_BTYPE) == VT_VOID ||
(type2->t & VT_BTYPE) == VT_VOID)
@ -1558,7 +1558,7 @@ static void check_comparison_pointer_types(SValue *p1, SValue *p2, int op)
if (op == '-')
goto invalid_operands;
else
warning("comparison of distinct pointer types lacks a cast");
tcc_warning("comparison of distinct pointer types lacks a cast");
}
}
@ -1589,7 +1589,7 @@ ST_FUNC void gen_op(int op)
/* if both pointers, then it must be the '-' op */
if (bt1 == VT_PTR && bt2 == VT_PTR) {
if (op != '-')
error("cannot use pointers here");
tcc_error("cannot use pointers here");
check_comparison_pointer_types(vtop - 1, vtop, op);
/* XXX: check that types are compatible */
if (vtop[-1].type.t & VT_VLA) {
@ -1610,7 +1610,7 @@ ST_FUNC void gen_op(int op)
} else {
/* exactly one pointer : must be '+' or '-'. */
if (op != '-' && op != '+')
error("cannot use pointers here");
tcc_error("cannot use pointers here");
/* Put pointer as first operand */
if (bt2 == VT_PTR) {
vswap();
@ -1623,7 +1623,7 @@ ST_FUNC void gen_op(int op)
else {
u = pointed_size(&vtop[-1].type);
if (u < 0)
error("unknown array element size");
tcc_error("unknown array element size");
#ifdef TCC_TARGET_X86_64
vpushll(u);
#else
@ -1664,7 +1664,7 @@ ST_FUNC void gen_op(int op)
/* floats can only be used for a few operations */
if (op != '+' && op != '-' && op != '*' && op != '/' &&
(op < TOK_ULT || op > TOK_GT))
error("invalid operands for binary operation");
tcc_error("invalid operands for binary operation");
goto std_op;
} else if (bt1 == VT_LLONG || bt2 == VT_LLONG) {
/* cast to biggest op */
@ -1962,7 +1962,7 @@ static void gen_cast(CType *type)
(dbt & VT_BTYPE) == VT_SHORT) {
if (sbt == VT_PTR) {
vtop->type.t = VT_INT;
warning("nonportable conversion from pointer to char/short");
tcc_warning("nonportable conversion from pointer to char/short");
}
force_charshort_cast(dbt);
} else if ((dbt & VT_BTYPE) == VT_INT) {
@ -2259,7 +2259,7 @@ static void gen_assign_cast(CType *dt)
dbt = dt->t & VT_BTYPE;
sbt = st->t & VT_BTYPE;
if (dt->t & VT_CONSTANT)
warning("assignment of read-only location");
tcc_warning("assignment of read-only location");
switch(dbt) {
case VT_PTR:
/* special cases for pointers */
@ -2268,7 +2268,7 @@ static void gen_assign_cast(CType *dt)
goto type_ok;
/* accept implicit pointer to integer cast with warning */
if (is_integer_btype(sbt)) {
warning("assignment makes pointer from integer without a cast");
tcc_warning("assignment makes pointer from integer without a cast");
goto type_ok;
}
type1 = pointed_type(dt);
@ -2276,7 +2276,7 @@ static void gen_assign_cast(CType *dt)
if (sbt == VT_FUNC) {
if ((type1->t & VT_BTYPE) != VT_VOID &&
!is_compatible_types(pointed_type(dt), st))
warning("assignment from incompatible pointer type");
tcc_warning("assignment from incompatible pointer type");
goto type_ok;
}
if (sbt != VT_PTR)
@ -2292,19 +2292,19 @@ static void gen_assign_cast(CType *dt)
tmp_type1.t &= ~(VT_UNSIGNED | VT_CONSTANT | VT_VOLATILE);
tmp_type2.t &= ~(VT_UNSIGNED | VT_CONSTANT | VT_VOLATILE);
if (!is_compatible_types(&tmp_type1, &tmp_type2))
warning("assignment from incompatible pointer type");
tcc_warning("assignment from incompatible pointer type");
}
/* check const and volatile */
if ((!(type1->t & VT_CONSTANT) && (type2->t & VT_CONSTANT)) ||
(!(type1->t & VT_VOLATILE) && (type2->t & VT_VOLATILE)))
warning("assignment discards qualifiers from pointer target type");
tcc_warning("assignment discards qualifiers from pointer target type");
break;
case VT_BYTE:
case VT_SHORT:
case VT_INT:
case VT_LLONG:
if (sbt == VT_PTR || sbt == VT_FUNC) {
warning("assignment makes integer from pointer without a cast");
tcc_warning("assignment makes integer from pointer without a cast");
}
/* XXX: more tests */
break;
@ -2317,7 +2317,7 @@ static void gen_assign_cast(CType *dt)
error:
type_to_str(buf1, sizeof(buf1), st, NULL);
type_to_str(buf2, sizeof(buf2), dt, NULL);
error("cannot cast '%s' to '%s'", buf1, buf2);
tcc_error("cannot cast '%s' to '%s'", buf1, buf2);
}
break;
}
@ -2340,7 +2340,7 @@ ST_FUNC void vstore(void)
vtop->type.t = ft & (VT_TYPE & ~(VT_BITFIELD | (-1 << VT_STRUCT_SHIFT)));
/* XXX: factorize */
if (ft & VT_CONSTANT)
warning("assignment of read-only location");
tcc_warning("assignment of read-only location");
} else {
delayed_cast = 0;
if (!(ft & VT_BITFIELD))
@ -2551,7 +2551,7 @@ static void parse_attribute(AttributeDef *ad)
next();
n = expr_const();
if (n <= 0 || (n & (n - 1)) != 0)
error("alignment must be a positive power of two");
tcc_error("alignment must be a positive power of two");
skip(')');
} else {
n = MAX_ALIGN;
@ -2618,7 +2618,7 @@ static void parse_attribute(AttributeDef *ad)
ad->mode = VT_INT + 1;
break;
default:
warning("__mode__(%s) not supported\n", get_tok_str(tok, NULL));
tcc_warning("__mode__(%s) not supported\n", get_tok_str(tok, NULL));
break;
}
next();
@ -2632,7 +2632,7 @@ static void parse_attribute(AttributeDef *ad)
break;
default:
if (tcc_state->warn_unsupported)
warning("'%s' attribute ignored", get_tok_str(t, NULL));
tcc_warning("'%s' attribute ignored", get_tok_str(t, NULL));
/* skip parameters */
if (tok == '(') {
int parenthesis = 0;
@ -2675,7 +2675,7 @@ static void struct_decl(CType *type, int u)
s = struct_find(v);
if (s) {
if (s->type.t != a)
error("invalid type");
tcc_error("invalid type");
goto do_decl;
}
} else {
@ -2693,7 +2693,7 @@ static void struct_decl(CType *type, int u)
if (tok == '{') {
next();
if (s->c != -1)
error("struct/union/enum already defined");
tcc_error("struct/union/enum already defined");
/* cannot be empty */
c = 0;
/* non empty enums are not allowed */
@ -2737,7 +2737,7 @@ static void struct_decl(CType *type, int u)
expect("identifier");
if ((type1.t & VT_BTYPE) == VT_FUNC ||
(type1.t & (VT_TYPEDEF | VT_STATIC | VT_EXTERN | VT_INLINE)))
error("invalid type for '%s'",
tcc_error("invalid type for '%s'",
get_tok_str(v, NULL));
}
if (tok == ':') {
@ -2745,10 +2745,10 @@ static void struct_decl(CType *type, int u)
bit_size = expr_const();
/* XXX: handle v = 0 case for messages */
if (bit_size < 0)
error("negative width in bit-field '%s'",
tcc_error("negative width in bit-field '%s'",
get_tok_str(v, NULL));
if (v && bit_size == 0)
error("zero width for bit-field '%s'",
tcc_error("zero width for bit-field '%s'",
get_tok_str(v, NULL));
}
size = type_size(&type1, &align);
@ -2770,10 +2770,10 @@ static void struct_decl(CType *type, int u)
bt != VT_BOOL &&
bt != VT_ENUM &&
bt != VT_LLONG)
error("bitfields must have scalar type");
tcc_error("bitfields must have scalar type");
bsize = size * 8;
if (bit_size > bsize) {
error("width of '%s' exceeds its type",
tcc_error("width of '%s' exceeds its type",
get_tok_str(v, NULL));
} else if (bit_size == bsize) {
/* no need for bit fields */
@ -2883,7 +2883,7 @@ static int parse_btype(CType *type, AttributeDef *ad)
next();
basic_type1:
if ((t & VT_BTYPE) != 0)
error("too many basic types");
tcc_error("too many basic types");
t |= u;
typespec_found = 1;
break;
@ -3036,7 +3036,7 @@ static int parse_btype(CType *type, AttributeDef *ad)
}
the_end:
if ((t & (VT_SIGNED|VT_UNSIGNED)) == (VT_SIGNED|VT_UNSIGNED))
error("signed and unsigned modifier");
tcc_error("signed and unsigned modifier");
if (tcc_state->char_is_unsigned) {
if ((t & (VT_SIGNED|VT_UNSIGNED|VT_BTYPE)) == VT_BYTE)
t |= VT_UNSIGNED;
@ -3115,7 +3115,7 @@ static void post_type(CType *type, AttributeDef *ad)
if (l != FUNC_OLD) {
if (!parse_btype(&pt, &ad1)) {
if (l) {
error("invalid type");
tcc_error("invalid type");
} else {
l = FUNC_OLD;
goto old_proto;
@ -3126,7 +3126,7 @@ static void post_type(CType *type, AttributeDef *ad)
break;
type_decl(&pt, &ad1, &n, TYPE_DIRECT | TYPE_ABSTRACT);
if ((pt.t & VT_BTYPE) == VT_VOID)
error("parameter declared as void");
tcc_error("parameter declared as void");
arg_size += (type_size(&pt, &align) + PTR_SIZE - 1) / PTR_SIZE;
} else {
old_proto:
@ -3185,10 +3185,10 @@ static void post_type(CType *type, AttributeDef *ad)
if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
n = vtop->c.i;
if (n < 0)
error("invalid array size");
tcc_error("invalid array size");
} else {
if (!is_integer_btype(vtop->type.t & VT_BTYPE))
error("size of variable length array should be an integer");
tcc_error("size of variable length array should be an integer");
t1 = VT_VLA;
}
}
@ -3358,7 +3358,7 @@ static void gfunc_param_typed(Sym *func, Sym *arg)
gen_cast(&type);
}
} else if (arg == NULL) {
error("too many arguments to function");
tcc_error("too many arguments to function");
} else {
type = arg->type;
type.t &= ~VT_CONSTANT; /* need to do that to avoid false warning */
@ -3571,7 +3571,7 @@ ST_FUNC void unary(void)
/* in order to force cast, we add zero */
unary();
if ((vtop->type.t & VT_BTYPE) == VT_PTR)
error("pointer not accepted for unary plus");
tcc_error("pointer not accepted for unary plus");
vpushi(0);
gen_op('+');
break;
@ -3586,7 +3586,7 @@ ST_FUNC void unary(void)
if (t == TOK_SIZEOF) {
if (!(type.t & VT_VLA)) {
if (size < 0)
error("sizeof applied to an incomplete type");
tcc_error("sizeof applied to an incomplete type");
vpushi(size);
} else {
vla_runtime_type_size(&type, &align);
@ -3632,10 +3632,10 @@ ST_FUNC void unary(void)
next();
skip('(');
if (tok != TOK_CINT) {
error("__builtin_frame_address only takes integers");
tcc_error("__builtin_frame_address only takes integers");
}
if (tokc.i != 0) {
error("TCC only supports __builtin_frame_address(0)");
tcc_error("TCC only supports __builtin_frame_address(0)");
}
next();
skip(')');
@ -3728,11 +3728,11 @@ ST_FUNC void unary(void)
s = sym_find(t);
if (!s) {
if (tok != '(')
error("'%s' undeclared", get_tok_str(t, NULL));
tcc_error("'%s' undeclared", get_tok_str(t, NULL));
/* for simple function calls, we tolerate undeclared
external reference to int() function */
if (tcc_state->warn_implicit_function_declaration)
warning("implicit declaration of function '%s'",
tcc_warning("implicit declaration of function '%s'",
get_tok_str(t, NULL));
s = external_global_sym(t, &func_old_type, 0);
}
@ -3783,7 +3783,7 @@ ST_FUNC void unary(void)
break;
}
if (!s)
error("field not found: %s", get_tok_str(tok & ~SYM_FIELD, NULL));
tcc_error("field not found: %s", get_tok_str(tok & ~SYM_FIELD, NULL));
/* add field offset to pointer */
vtop->type = char_pointer_type; /* change type to 'char *' */
vpushi(s->c);
@ -3869,7 +3869,7 @@ ST_FUNC void unary(void)
}
}
if (sa)
error("too few arguments to function");
tcc_error("too few arguments to function");
skip(')');
if (!nocode_wanted) {
gfunc_call(nb_args);
@ -4383,7 +4383,7 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym,
case VT_FUNC:
for(p=vtop->type.ref;p;p=p->prev)
if(p->prev==s)
error("unsupported expression type");
tcc_error("unsupported expression type");
}
}
/* pop locally defined symbols */
@ -4441,14 +4441,14 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym,
} else if (tok == TOK_BREAK) {
/* compute jump */
if (!bsym)
error("cannot break");
tcc_error("cannot break");
*bsym = gjmp(*bsym);
next();
skip(';');
} else if (tok == TOK_CONTINUE) {
/* compute jump */
if (!csym)
error("cannot continue");
tcc_error("cannot continue");
*csym = gjmp(*csym);
next();
skip(';');
@ -4537,7 +4537,7 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym,
next();
v2 = expr_const();
if (v2 < v1)
warning("empty case range");
tcc_warning("empty case range");
}
/* since a case is like a label, we must skip it with a jmp */
b = gjmp(0);
@ -4566,7 +4566,7 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym,
if (!def_sym)
expect("switch");
if (*def_sym)
error("too many 'default'");
tcc_error("too many 'default'");
*def_sym = ind;
is_expr = 0;
goto block_after_label;
@ -4608,7 +4608,7 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym,
s = label_find(b);
if (s) {
if (s->r == LABEL_DEFINED)
error("duplicate label '%s'", get_tok_str(s->v, NULL));
tcc_error("duplicate label '%s'", get_tok_str(s->v, NULL));
gsym(s->jnext);
s->r = LABEL_DEFINED;
} else {
@ -4618,7 +4618,7 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym,
/* we accept this, but it is a mistake */
block_after_label:
if (tok == '}') {
warning("deprecated use of label at end of compound statement");
tcc_warning("deprecated use of label at end of compound statement");
} else {
if (is_expr)
vpop();
@ -4730,7 +4730,7 @@ static void decl_designator(CType *type, Section *sec, unsigned long c,
} else {
f = *cur_field;
if (!f)
error("too many field init");
tcc_error("too many field init");
/* XXX: fix this mess by using explicit storage field */
type1 = f->type;
type1.t |= (type->t & ~VT_TYPE);
@ -4747,7 +4747,7 @@ static void decl_designator(CType *type, Section *sec, unsigned long c,
int i;
if (!sec)
error("range init not supported yet for dynamic storage");
tcc_error("range init not supported yet for dynamic storage");
c_end = c + nb_elems * elem_size;
if (c_end > sec->data_allocated)
section_realloc(sec, c_end);
@ -4785,7 +4785,7 @@ static void init_putv(CType *type, Section *sec, unsigned long c,
global_expr = saved_global_expr;
/* NOTE: symbols are accepted */
if ((vtop->r & (VT_VALMASK | VT_LVAL)) != VT_CONST)
error("initializer element is not constant");
tcc_error("initializer element is not constant");
break;
case EXPR_ANY:
expr_eq();
@ -4822,7 +4822,7 @@ static void init_putv(CType *type, Section *sec, unsigned long c,
bt == VT_LDOUBLE ||
bt == VT_LLONG ||
(bt == VT_INT && bit_size != 32)))
error("initializer element is not computable at load time");
tcc_error("initializer element is not computable at load time");
switch(bt) {
case VT_BOOL:
vtop->c.i = (vtop->c.i != 0);
@ -4901,7 +4901,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c,
vstore();
vpop();
#else
error("variable length arrays unsupported for this target");
tcc_error("variable length arrays unsupported for this target");
#endif
} else if (type->t & VT_ARRAY) {
s = type->ref;
@ -4914,7 +4914,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c,
if ((first && tok != TOK_LSTR && tok != TOK_STR) ||
tok == '{') {
if (tok != '{')
error("character array initializer must be a literal,"
tcc_error("character array initializer must be a literal,"
" optionally enclosed in braces");
skip('{');
no_oblock = 0;
@ -4945,7 +4945,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c,
nb = n - array_length;
if (!size_only) {
if (cstr_len > nb)
warning("initializer-string for array is too long");
tcc_warning("initializer-string for array is too long");
/* in order to go faster for common case (char
string in global variable, we handle it
specifically */
@ -4978,7 +4978,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c,
while (tok != '}') {
decl_designator(type, sec, c, &index, NULL, size_only);
if (n >= 0 && index >= n)
error("index too large");
tcc_error("index too large");
/* must put zero in holes (note that doing it that way
ensures that it even works with designators) */
if (!size_only && array_length < index) {
@ -5034,7 +5034,7 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c,
type_decl(&type1, &ad1, &n, TYPE_ABSTRACT);
#if 0
if (!is_assignable_types(type, &type1))
error("invalid type for cast");
tcc_error("invalid type for cast");
#endif
skip(')');
}
@ -5162,7 +5162,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r,
tok_str_new(&init_str);
if (size < 0 || (flexible_array && has_init)) {
if (!has_init)
error("unknown type size");
tcc_error("unknown type size");
/* get all init string */
if (has_init == 2) {
/* only get strings */
@ -5174,7 +5174,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r,
level = 0;
while (level > 0 || (tok != ',' && tok != ';')) {
if (tok < 0)
error("unexpected end of file in initializer");
tcc_error("unexpected end of file in initializer");
tok_str_add_tok(&init_str);
if (tok == '{')
level++;
@ -5204,7 +5204,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r,
/* if still unknown size, error */
size = type_size(type, &align);
if (size < 0)
error("unknown type size");
tcc_error("unknown type size");
}
if (flexible_array)
size += flexible_array->type.ref->c * pointed_size(&flexible_array->type);
@ -5254,7 +5254,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r,
sym = sym_find(v);
if (sym) {
if (!is_compatible_types(&sym->type, type))
error("incompatible types for redefinition of '%s'",
tcc_error("incompatible types for redefinition of '%s'",
get_tok_str(v, NULL));
if (sym->type.t & VT_EXTERN) {
/* if the variable is extern, it was not allocated */
@ -5413,12 +5413,12 @@ static void func_decl_list(Sym *func_sym)
goto found;
s = s->next;
}
error("declaration for parameter '%s' but no such parameter",
tcc_error("declaration for parameter '%s' but no such parameter",
get_tok_str(v, NULL));
found:
/* check that no storage specifier except 'register' was given */
if (type.t & VT_STORAGE)
error("storage class specified for '%s'", get_tok_str(v, NULL));
tcc_error("storage class specified for '%s'", get_tok_str(v, NULL));
convert_parameter_type(&type);
/* we can add the type (NOTE: it could be local to the function) */
s->type = type;
@ -5567,7 +5567,7 @@ static int decl0(int l, int is_for_loop_init)
#endif
if ((type.t & VT_BTYPE) == VT_FUNC) {
if ((type.t & VT_STATIC) && (l == VT_LOCAL)) {
error("function without file scope cannot be static");
tcc_error("function without file scope cannot be static");
}
/* if old style function prototype, we accept a
declaration list */
@ -5598,7 +5598,7 @@ static int decl0(int l, int is_for_loop_init)
#endif
if (tok == '{') {
if (l == VT_LOCAL)
error("cannot use local functions");
tcc_error("cannot use local functions");
if ((type.t & VT_BTYPE) != VT_FUNC)
expect("function definition");
@ -5633,7 +5633,7 @@ static int decl0(int l, int is_for_loop_init)
if (!is_compatible_types(&sym->type, &type)) {
func_error1:
error("incompatible types for redefinition of '%s'",
tcc_error("incompatible types for redefinition of '%s'",
get_tok_str(v, NULL));
}
/* if symbol is already defined, then put complete type */
@ -5660,7 +5660,7 @@ static int decl0(int l, int is_for_loop_init)
for(;;) {
int t;
if (tok == TOK_EOF)
error("unexpected end of file");
tcc_error("unexpected end of file");
tok_str_add_tok(&func_str);
t = tok;
next();
@ -5708,7 +5708,7 @@ static int decl0(int l, int is_for_loop_init)
}
has_init = (tok == '=');
if (has_init && (type.t & VT_VLA))
error("Variable length array cannot be initialized");
tcc_error("Variable length array cannot be initialized");
if ((btype.t & VT_EXTERN) || ((type.t & VT_BTYPE) == VT_FUNC) ||
((type.t & VT_ARRAY) && (type.t & VT_STATIC) &&
!has_init && l == VT_CONST && type.ref->c < 0)) {
@ -5728,7 +5728,7 @@ static int decl0(int l, int is_for_loop_init)
alias_target = sym_find(ad.alias_target);
if (!alias_target || !alias_target->c)
error("unsupported forward __alias__ attribute");
tcc_error("unsupported forward __alias__ attribute");
esym = &((Elf32_Sym *)symtab_section->data)[alias_target->c];
tsec.sh_num = esym->st_shndx;
put_extern_sym2(sym, &tsec, esym->st_value, esym->st_size, 0);

12
tccpe.c
View File

@ -595,7 +595,7 @@ static int pe_write(struct pe_info *pe)
op = fopen(pe->filename, "wb");
if (NULL == op) {
error_noabort("could not write '%s': %s", pe->filename, strerror(errno));
tcc_error_noabort("could not write '%s': %s", pe->filename, strerror(errno));
return -1;
}
@ -841,7 +841,7 @@ static void pe_build_imports(struct pe_info *pe)
v = (ADDR3264)GetProcAddress(dllref->handle, name);
}
if (!v)
error_noabort("undefined symbol '%s'", name);
tcc_error_noabort("undefined symbol '%s'", name);
}
#endif
} else {
@ -941,7 +941,7 @@ static void pe_build_exports(struct pe_info *pe)
strcpy(tcc_fileextension(buf), ".def");
op = fopen(buf, "w");
if (NULL == op) {
error_noabort("could not create '%s': %s", buf, strerror(errno));
tcc_error_noabort("could not create '%s': %s", buf, strerror(errno));
} else {
fprintf(op, "LIBRARY %s\n\nEXPORTS\n", dllname);
if (pe->s1->verbose)
@ -1287,7 +1287,7 @@ static int pe_check_symbols(struct pe_info *pe)
}
not_found:
error_noabort("undefined symbol '%s'", name);
tcc_error_noabort("undefined symbol '%s'", name);
ret = -1;
} else if (pe->s1->rdynamic
@ -1774,7 +1774,7 @@ static void pe_add_runtime_ex(TCCState *s1, struct pe_info *pe)
if (PE_DLL != pe_type && PE_GUI != pe_type)
break;
} else if (tcc_add_library(s1, p) < 0)
error_noabort("cannot find library: %s", p);
tcc_error_noabort("cannot find library: %s", p);
}
}
@ -1871,7 +1871,7 @@ ST_FUNC int pe_output_file(TCCState * s1, const char *filename)
tcc_free(pe.sec_info);
} else {
#ifndef TCC_IS_NATIVE
error_noabort("-run supported only on native platform");
tcc_error_noabort("-run supported only on native platform");
#endif
pe.thunk = data_section;
pe_build_imports(&pe);

96
tccpp.c
View File

@ -90,13 +90,13 @@ static void macro_subst(
ST_FUNC void skip(int c)
{
if (tok != c)
error("'%c' expected (got \"%s\")", c, get_tok_str(tok, &tokc));
tcc_error("'%c' expected (got \"%s\")", c, get_tok_str(tok, &tokc));
next();
}
ST_FUNC void expect(const char *msg)
{
error("%s expected", msg);
tcc_error("%s expected", msg);
}
/* ------------------------------------------------------------------------- */
@ -113,7 +113,7 @@ static void cstr_realloc(CString *cstr, int new_size)
size = size * 2;
data = tcc_realloc(cstr->data_allocated, size);
if (!data)
error("memory full");
tcc_error("memory full");
cstr->data_allocated = data;
cstr->size_allocated = size;
cstr->data = data;
@ -194,14 +194,14 @@ static TokenSym *tok_alloc_new(TokenSym **pts, const char *str, int len)
int i;
if (tok_ident >= SYM_FIRST_ANOM)
error("memory full");
tcc_error("memory full");
/* expand token table if needed */
i = tok_ident - TOK_IDENT;
if ((i % TOK_ALLOC_INCR) == 0) {
ptable = tcc_realloc(table_ident, (i + TOK_ALLOC_INCR) * sizeof(TokenSym *));
if (!ptable)
error("memory full");
tcc_error("memory full");
table_ident = ptable;
}
@ -424,7 +424,7 @@ static int handle_stray_noerror(void)
static void handle_stray(void)
{
if (handle_stray_noerror())
error("stray '\\' in program");
tcc_error("stray '\\' in program");
}
/* skip the stray and handle the \\n case. Output an error if
@ -584,7 +584,7 @@ ST_FUNC uint8_t *parse_comment(uint8_t *p)
c = handle_eob();
p = file->buf_ptr;
if (c == CH_EOF) {
error("unexpected end of file in comment");
tcc_error("unexpected end of file in comment");
} else if (c == '\\') {
p++;
}
@ -631,7 +631,7 @@ static uint8_t *parse_pp_string(uint8_t *p,
if (c == CH_EOF) {
unterminated_string:
/* XXX: indicate line number of start of string */
error("missing terminating %c character", sep);
tcc_error("missing terminating %c character", sep);
} else if (c == '\\') {
/* escape : just skip \[\r]\n */
PEEKC_EOB(c, p);
@ -806,7 +806,7 @@ static inline int tok_ext_size(int t)
case TOK_STR:
case TOK_LSTR:
case TOK_PPNUM:
error("unsupported token");
tcc_error("unsupported token");
return 1;
case TOK_CDOUBLE:
case TOK_CLLONG:
@ -845,7 +845,7 @@ static int *tok_str_realloc(TokenString *s)
}
str = tcc_realloc(s->str, len * sizeof(int));
if (!str)
error("memory full");
tcc_error("memory full");
s->allocated_len = len;
s->str = str;
return str;
@ -1019,7 +1019,7 @@ ST_INLN void define_push(int v, int macro_type, int *str, Sym *first_arg)
s = define_find(v);
if (s && !macro_is_equal(s->d, str))
warning("%s redefined", get_tok_str(v, NULL));
tcc_warning("%s redefined", get_tok_str(v, NULL));
s = sym_push2(&define_stack, v, macro_type, 0);
s->d = str;
@ -1100,9 +1100,9 @@ ST_FUNC void label_pop(Sym **ptop, Sym *slast)
for(s = *ptop; s != slast; s = s1) {
s1 = s->prev;
if (s->r == LABEL_DECLARED) {
warning("label '%s' declared but not used", get_tok_str(s->v, NULL));
tcc_warning("label '%s' declared but not used", get_tok_str(s->v, NULL));
} else if (s->r == LABEL_FORWARD) {
error("label '%s' used but not defined",
tcc_error("label '%s' used but not defined",
get_tok_str(s->v, NULL));
} else {
if (s->c) {
@ -1181,7 +1181,7 @@ ST_FUNC void parse_define(void)
v = tok;
if (v < TOK_IDENT)
error("invalid macro name '%s'", get_tok_str(tok, &tokc));
tcc_error("invalid macro name '%s'", get_tok_str(tok, &tokc));
/* XXX: should check if same macro (ANSI) */
first = NULL;
t = MACRO_OBJ;
@ -1202,7 +1202,7 @@ ST_FUNC void parse_define(void)
next_nomacro();
}
if (varg < TOK_IDENT)
error("badly punctuated parameter list");
tcc_error("badly punctuated parameter list");
s = sym_push2(&define_stack, varg | SYM_FIELD, is_vaargs, 0);
*ps = s;
ps = &s->next;
@ -1320,7 +1320,7 @@ static void pragma_parse(TCCState *s1)
next();
if (s1->pack_stack_ptr <= s1->pack_stack) {
stk_error:
error("out of pack stack");
tcc_error("out of pack stack");
}
s1->pack_stack_ptr--;
} else {
@ -1335,7 +1335,7 @@ static void pragma_parse(TCCState *s1)
}
if (tok != TOK_CINT) {
pack_error:
error("invalid pack pragma");
tcc_error("invalid pack pragma");
}
val = tokc.i;
if (val < 1 || val > 16 || (val & (val - 1)) != 0)
@ -1412,7 +1412,7 @@ ST_FUNC void preprocess(int is_bof)
while (tok != TOK_LINEFEED) {
if (tok != TOK_STR) {
include_syntax:
error("'#include' expects \"FILENAME\" or <FILENAME>");
tcc_error("'#include' expects \"FILENAME\" or <FILENAME>");
}
pstrcat(buf, sizeof(buf), (char *)tokc.cstr->data);
next();
@ -1435,7 +1435,7 @@ ST_FUNC void preprocess(int is_bof)
}
if (s1->include_stack_ptr >= s1->include_stack + INCLUDE_STACK_SIZE)
error("#include recursion too deep");
tcc_error("#include recursion too deep");
n = s1->nb_include_paths + s1->nb_sysinclude_paths;
for (i = -2; i < n; ++i) {
@ -1512,7 +1512,7 @@ ST_FUNC void preprocess(int is_bof)
ch = file->buf_ptr[0];
goto the_end;
}
error("include file '%s' not found", buf);
tcc_error("include file '%s' not found", buf);
include_done:
break;
case TOK_IFNDEF:
@ -1526,7 +1526,7 @@ include_done:
do_ifdef:
next_nomacro();
if (tok < TOK_IDENT)
error("invalid argument for '#if%sdef'", c ? "n" : "");
tcc_error("invalid argument for '#if%sdef'", c ? "n" : "");
if (is_bof) {
if (c) {
#ifdef INC_DEBUG
@ -1538,22 +1538,22 @@ include_done:
c = (define_find(tok) != 0) ^ c;
do_if:
if (s1->ifdef_stack_ptr >= s1->ifdef_stack + IFDEF_STACK_SIZE)
error("memory full");
tcc_error("memory full");
*s1->ifdef_stack_ptr++ = c;
goto test_skip;
case TOK_ELSE:
if (s1->ifdef_stack_ptr == s1->ifdef_stack)
error("#else without matching #if");
tcc_error("#else without matching #if");
if (s1->ifdef_stack_ptr[-1] & 2)
error("#else after #else");
tcc_error("#else after #else");
c = (s1->ifdef_stack_ptr[-1] ^= 3);
goto test_else;
case TOK_ELIF:
if (s1->ifdef_stack_ptr == s1->ifdef_stack)
error("#elif without matching #if");
tcc_error("#elif without matching #if");
c = s1->ifdef_stack_ptr[-1];
if (c > 1)
error("#elif after #else");
tcc_error("#elif after #else");
/* last #if/#elif expression was true: we skip */
if (c == 1)
goto skip;
@ -1572,7 +1572,7 @@ include_done:
break;
case TOK_ENDIF:
if (s1->ifdef_stack_ptr <= file->ifdef_stack_ptr)
error("#endif without matching #if");
tcc_error("#endif without matching #if");
s1->ifdef_stack_ptr--;
/* '#ifndef macro' was at the start of file. Now we check if
an '#endif' is exactly at the end of file */
@ -1591,12 +1591,12 @@ include_done:
case TOK_LINE:
next();
if (tok != TOK_CINT)
error("#line");
tcc_error("#line");
file->line_num = tokc.i - 1; /* the line number will be incremented after */
next();
if (tok != TOK_LINEFEED) {
if (tok != TOK_STR)
error("#line");
tcc_error("#line");
pstrcpy(file->filename, sizeof(file->filename),
(char *)tokc.cstr->data);
}
@ -1618,9 +1618,9 @@ include_done:
}
*q = '\0';
if (c == TOK_ERROR)
error("#error %s", buf);
tcc_error("#error %s", buf);
else
warning("#warning %s", buf);
tcc_warning("#warning %s", buf);
break;
case TOK_PRAGMA:
pragma_parse(s1);
@ -1631,7 +1631,7 @@ include_done:
to emulate cpp behaviour */
} else {
if (!(saved_parse_flags & PARSE_FLAG_ASM_COMMENTS))
warning("Ignoring unknown preprocessing directive #%s", get_tok_str(tok, &tokc));
tcc_warning("Ignoring unknown preprocessing directive #%s", get_tok_str(tok, &tokc));
else {
/* this is a gas line comment in an 'S' file. */
file->buf_ptr = parse_line_comment(file->buf_ptr);
@ -1734,9 +1734,9 @@ static void parse_escape_string(CString *outstr, const uint8_t *buf, int is_long
default:
invalid_escape:
if (c >= '!' && c <= '~')
warning("unknown escape sequence: \'\\%c\'", c);
tcc_warning("unknown escape sequence: \'\\%c\'", c);
else
warning("unknown escape sequence: \'\\x%x\'", c);
tcc_warning("unknown escape sequence: \'\\x%x\'", c);
break;
}
}
@ -1821,7 +1821,7 @@ static void parse_number(const char *p)
break;
if (q >= token_buf + STRING_MAX_SIZE) {
num_too_long:
error("number too long");
tcc_error("number too long");
}
*q++ = ch;
ch = *p++;
@ -1870,7 +1870,7 @@ static void parse_number(const char *p)
break;
}
if (t >= b)
error("invalid digit");
tcc_error("invalid digit");
bn_lshift(bn, shift, t);
frac_bits += shift;
ch = *p++;
@ -1999,14 +1999,14 @@ static void parse_number(const char *p)
} else {
t = t - '0';
if (t >= b)
error("invalid digit");
tcc_error("invalid digit");
}
n1 = n;
n = n * b + t;
/* detect overflow */
/* XXX: this test is not reliable */
if (n < n1)
error("integer constant overflow");
tcc_error("integer constant overflow");
}
/* XXX: not exactly ANSI compliant */
@ -2026,7 +2026,7 @@ static void parse_number(const char *p)
t = toup(ch);
if (t == 'L') {
if (lcount >= 2)
error("three 'l's in integer constant");
tcc_error("three 'l's in integer constant");
lcount++;
if (lcount == 2) {
if (tok == TOK_CINT)
@ -2037,7 +2037,7 @@ static void parse_number(const char *p)
ch = *p++;
} else if (t == 'U') {
if (ucount >= 1)
error("two 'u's in integer constant");
tcc_error("two 'u's in integer constant");
ucount++;
if (tok == TOK_CINT)
tok = TOK_CUINT;
@ -2054,7 +2054,7 @@ static void parse_number(const char *p)
tokc.ull = n;
}
if (ch)
error("invalid number\n");
tcc_error("invalid number\n");
}
@ -2119,7 +2119,7 @@ static inline void next_nomacro1(void)
} else if (!(parse_flags & PARSE_FLAG_PREPROCESS)) {
tok = TOK_EOF;
} else if (s1->ifdef_stack_ptr != file->ifdef_stack_ptr) {
error("missing #endif");
tcc_error("missing #endif");
} else if (s1->include_stack_ptr == s1->include_stack) {
/* no include left : end of file. */
tok = TOK_EOF;
@ -2333,9 +2333,9 @@ maybe_newline:
else
char_size = sizeof(nwchar_t);
if (tokcstr.size <= char_size)
error("empty character constant");
tcc_error("empty character constant");
if (tokcstr.size > 2 * char_size)
warning("multi-character character constant");
tcc_warning("multi-character character constant");
if (!is_long) {
tokc.i = *(int8_t *)tokcstr.data;
tok = TOK_CCHAR;
@ -2488,7 +2488,7 @@ maybe_newline:
p++;
break;
default:
error("unrecognized character \\x%02x", c);
tcc_error("unrecognized character \\x%02x", c);
break;
}
tok_flags = 0;
@ -2719,7 +2719,7 @@ static int macro_subst_tok(TokenString *tok_str,
if (!args && !sa && tok == ')')
break;
if (!sa)
error("macro '%s' used with too many args",
tcc_error("macro '%s' used with too many args",
get_tok_str(s->v, 0));
tok_str_new(&str);
parlevel = spc = 0;
@ -2756,7 +2756,7 @@ static int macro_subst_tok(TokenString *tok_str,
next_nomacro();
}
if (sa) {
error("macro '%s' used with too few args",
tcc_error("macro '%s' used with too few args",
get_tok_str(s->v, 0));
}
@ -2843,7 +2843,7 @@ static inline int *macro_twosharps(const int *macro_str)
if (0 == *file->buf_ptr)
break;
tok_str_add2(&macro_str1, tok, &tokc);
warning("pasting \"%.*s\" and \"%s\" does not give a valid preprocessing token",
tcc_warning("pasting \"%.*s\" and \"%s\" does not give a valid preprocessing token",
n, cstr.data, (char*)cstr.data + n);
}
tcc_close();

View File

@ -58,13 +58,13 @@ LIBTCCAPI int tcc_relocate(TCCState *s1)
s1->write_mem = mmap (NULL, ret, PROT_READ|PROT_WRITE,
MAP_SHARED, fd, 0);
if(s1->write_mem == MAP_FAILED){
error("/tmp not writeable");
tcc_error("/tmp not writeable");
return -1;
}
s1->runtime_mem = mmap (NULL, ret, PROT_READ|PROT_EXEC,
MAP_SHARED, fd, 0);
if(s1->runtime_mem == MAP_FAILED){
error("/tmp not executable");
tcc_error("/tmp not executable");
return -1;
}
ret = tcc_relocate_ex(s1, s1->write_mem);