---------------------------------------------------------------------- #define hexCh(c (c >= 10 ? 'a' + c - 10 : '0' + c) hexCh(c); out: jiang@jiang:~/test$ ./tcc -E c4.c # 1 "c4.c" (c >= 10 ? 'a' + c - 10 : '0' + c); --------------------------------------------------------------- #define hexCh(c/3) (c >= 10 ? 'a' + c - 10 : '0' + c) hexCh(c); out: jiang@jiang:~/test$ ./tcc -E c4.c # 1 "c4.c" /3) (c >= 10 ? 'a' + c - 10 : '0' + c); jiang@jiang:~/test$ after patch: # 1 "c4.c" c4.c:1: error: may not appear in macro parameter list: "(" jiang@jiang:~/test$ jiang@jiang:~/test$ ./tcc -E c4.c # 1 "c4.c" c4.c:1: error: may not appear in macro parameter list: "/" jiang@jiang:~/test$
Unified · Split
| @@ -1239,16 +1239,15 @@ ST_FUNC void parse_define(void) · 1238 unmodified lines | ||
| 1239 | 1239 | next_nomacro(); |
| 1240 | 1240 | } |
| 1241 | 1241 | if (varg < TOK_IDENT) |
| 1242 | − tcc_error("badly punctuated parameter list"); | |
| 1242 | + tcc_error( "\'%s\' may not appear in parameter list", get_tok_str(varg, NULL)); | |
| 1243 | 1243 | s = sym_push2(&define_stack, varg | SYM_FIELD, is_vaargs, 0); |
| 1244 | 1244 | *ps = s; |
| 1245 | 1245 | ps = &s->next; |
| 1246 | 1246 | if (tok != ',') |
| 1247 | − break; | |
| 1247 | + continue; | |
| 1248 | 1248 | next_nomacro(); |
| 1249 | 1249 | } |
| 1250 | − if (tok == ')') | |
| 1251 | − next_nomacro_spc(); | |
| 1250 | + next_nomacro_spc(); | |
| 1252 | 1251 | t = MACRO_FUNC; |
| 1253 | 1252 | } |
| 1254 | 1253 | tok_str_new(&str); |
| @@ -0,0 +1,9 @@ | ||
| 1 | +#include <stdio.h> | |
| 2 | +#define hexCh(c (c >= 10 ? 'a' + c - 10 : '0' + c) | |
| 3 | + | |
| 4 | +int main(void) | |
| 5 | +{ | |
| 6 | + int c = 0xa; | |
| 7 | + printf("hex: %c\n", hexCh(c)); | |
| 8 | + return 0; | |
| 9 | +} | |
| @@ -0,0 +1 @@ | ||
| 1 | +68_macro_concat.c:2: error: '(' may not appear in parameter list | |
| @@ -0,0 +1,9 @@ | ||
| 1 | +#include <stdio.h> | |
| 2 | +#define hexCh(c/3) (c >= 10 ? 'a' + c - 10 : '0' + c) | |
| 3 | + | |
| 4 | +int main(void) | |
| 5 | +{ | |
| 6 | + int c = 0xa; | |
| 7 | + printf("hex: %c\n", hexCh(c)); | |
| 8 | + return 0; | |
| 9 | +} | |
| @@ -0,0 +1 @@ | ||
| 1 | +69_macro_concat.c:2: error: '/' may not appear in parameter list | |
| @@ -82,7 +82,9 @@ TESTS = \ · 81 unmodified lines | ||
| 82 | 82 | 64_macro_nesting.test \ |
| 83 | 83 | 65_macro_concat_start.test \ |
| 84 | 84 | 66_macro_concat_end.test \ |
| 85 | − 67_macro_concat.test | |
| 85 | + 67_macro_concat.test \ | |
| 86 | + 68_macro_concat.test \ | |
| 87 | + 69_macro_concat.test | |
| 86 | 88 | |
| 87 | 89 | # 34_array_assignment.test -- array assignment is not in C standard |
| 88 | 90 | |