From 280e20b1d3a6c5ef88db4bfb074be771e595179f Mon Sep 17 00:00:00 2001 From: grischka Date: Thu, 14 Jan 2010 20:57:50 +0100 Subject: [PATCH] tccpp: warn about #define redefinition --- tccpp.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tccpp.c b/tccpp.c index 162d0818..56b99d0d 100644 --- a/tccpp.c +++ b/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; -- 2.11.4.GIT