diff options
| author | grischka <grischka> | 2010-01-14 20:57:50 +0100 |
|---|---|---|
| committer | grischka <grischka> | 2010-01-14 20:59:44 +0100 |
| commit | 280e20b1d3a6c5ef88db4bfb074be771e595179f (patch) | |
| tree | 886b94b81d9cad99fad9b7d41dbe1a20000edd62 /tccpp.c | |
| parent | e20bf69ac5adf3607c6e60ffdd5a0bb40b8f11ed (diff) | |
| download | tinycc-280e20b1d3a6c5ef88db4bfb074be771e595179f.tar.gz tinycc-280e20b1d3a6c5ef88db4bfb074be771e595179f.tar.bz2 | |
tccpp: warn about #define redefinition
Diffstat (limited to 'tccpp.c')
| -rw-r--r-- | tccpp.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -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; |
