History

bug:

---------------------------------------------------------------------- #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$

jiang committed 12 years ago

Commit a3fc5431 parent 79951236 files · +26 −5Browse files

Unified · Split

6 files
  1. tccpp.c +3 −4
  2. tests/tests2/68_macro_concat.c +9 −0
  3. tests/tests2/68_macro_concat.expect +1 −0
  4. tests/tests2/69_macro_concat.c +9 −0
  5. tests/tests2/69_macro_concat.expect +1 −0
  6. tests/tests2/Makefile +3 −1
tccpp.c+3−4
@@ -1239,16 +1239,15 @@ ST_FUNC void parse_define(void) · 1238 unmodified lines
12391239 next_nomacro();
12401240 }
12411241 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));
12431243 s = sym_push2(&define_stack, varg | SYM_FIELD, is_vaargs, 0);
12441244 *ps = s;
12451245 ps = &s->next;
12461246 if (tok != ',')
1247− break;
1247+ continue;
12481248 next_nomacro();
12491249 }
1250− if (tok == ')')
1251− next_nomacro_spc();
1250+ next_nomacro_spc();
12521251 t = MACRO_FUNC;
12531252 }
12541253 tok_str_new(&str);
tests/tests2/68_macro_concat.c+9−0
@@ -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+}
tests/tests2/68_macro_concat.expect+1−0
@@ -0,0 +1 @@
1+68_macro_concat.c:2: error: '(' may not appear in parameter list
tests/tests2/69_macro_concat.c+9−0
@@ -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+}
tests/tests2/69_macro_concat.expect+1−0
@@ -0,0 +1 @@
1+69_macro_concat.c:2: error: '/' may not appear in parameter list
tests/tests2/Makefile+3−1
@@ -82,7 +82,9 @@ TESTS = \ · 81 unmodified lines
8282 64_macro_nesting.test \
8383 65_macro_concat_start.test \
8484 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
8688
8789 # 34_array_assignment.test -- array assignment is not in C standard
8890

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