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
997997 } \
998998 }
999999
1000+static 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+
10001015 /* defines handling */
10011016 ST_INLN void define_push(int v, int macro_type, int *str, Sym *first_arg)
10021017 {
10031018 Sym *s;
10041019
1020+ s = define_find(v);
1021+ if (s && !macro_is_equal(s->d, str))
1022+ warning("%s redefined", get_tok_str(v, NULL));
1023+
10051024 s = sym_push2(&define_stack, v, macro_type, 0);
10061025 s->d = str;
10071026 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