mirror of
https://github.com/frida/tinycc
synced 2025-03-02 22:11:30 +03:00
tccpp: warn about #define redefinition
This commit is contained in:
parent
e20bf69ac5
commit
280e20b1d3
19
tccpp.c
19
tccpp.c
@ -997,11 +997,30 @@ ST_FUNC void tok_str_add_tok(TokenString *s)
|
||||
} \
|
||||
}
|
||||
|
||||
static int macro_is_equal(const int *a, const int *b)
|
||||
{
|
||||
char buf[STRING_MAX_SIZE + 1];
|
||||
CValue cv;
|
||||
int t;
|
||||
while (*a && *b) {
|
||||
TOK_GET(t, a, cv);
|
||||
pstrcpy(buf, sizeof buf, get_tok_str(t, &cv));
|
||||
TOK_GET(t, b, cv);
|
||||
if (strcmp(buf, get_tok_str(t, &cv)))
|
||||
return 0;
|
||||
}
|
||||
return !(*a || *b);
|
||||
}
|
||||
|
||||
/* defines handling */
|
||||
ST_INLN void define_push(int v, int macro_type, int *str, Sym *first_arg)
|
||||
{
|
||||
Sym *s;
|
||||
|
||||
s = define_find(v);
|
||||
if (s && !macro_is_equal(s->d, str))
|
||||
warning("%s redefined", get_tok_str(v, NULL));
|
||||
|
||||
s = sym_push2(&define_stack, v, macro_type, 0);
|
||||
s->d = str;
|
||||
s->next = first_arg;
|
||||
|
Loading…
x
Reference in New Issue
Block a user