History

tccpp: warn about #define redefinition

grischka committed 16 years ago

Commit 280e20b1 parent e20bf691 file · +19 −0Browse files

Unified · Split

tccpp.c+19−0
@@ -997,11 +997,30 @@ ST_FUNC void tok_str_add_tok(TokenString *s) · 996 unmodified lines
997 } \997 } \
998}998}
999 999
1000static int macro_is_equal(const int *a, const int *b)
1001{
1002 char buf[STRING_MAX_SIZE + 1];
1003 CValue cv;
1004 int t;
1005 while (*a && *b) {
1006 TOK_GET(t, a, cv);
1007 pstrcpy(buf, sizeof buf, get_tok_str(t, &cv));
1008 TOK_GET(t, b, cv);
1009 if (strcmp(buf, get_tok_str(t, &cv)))
1010 return 0;
1011 }
1012 return !(*a || *b);
1013}
1014
1000/* defines handling */1015/* defines handling */
1001ST_INLN void define_push(int v, int macro_type, int *str, Sym *first_arg)1016ST_INLN void define_push(int v, int macro_type, int *str, Sym *first_arg)
1002{1017{
1003 Sym *s;1018 Sym *s;
1004 1019
1020 s = define_find(v);
1021 if (s && !macro_is_equal(s->d, str))
1022 warning("%s redefined", get_tok_str(v, NULL));
1023
1005 s = sym_push2(&define_stack, v, macro_type, 0);1024 s = sym_push2(&define_stack, v, macro_type, 0);
1006 s->d = str;1025 s->d = str;
1007 s->next = first_arg;1026 s->next = first_arg;

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