mirror of
https://github.com/frida/tinycc
synced 2024-11-24 00:29:38 +03:00
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$
This commit is contained in:
parent
799512388c
commit
a3fc543459
7
tccpp.c
7
tccpp.c
@ -1239,16 +1239,15 @@ ST_FUNC void parse_define(void)
|
|||||||
next_nomacro();
|
next_nomacro();
|
||||||
}
|
}
|
||||||
if (varg < TOK_IDENT)
|
if (varg < TOK_IDENT)
|
||||||
tcc_error("badly punctuated parameter list");
|
tcc_error( "\'%s\' may not appear in parameter list", get_tok_str(varg, NULL));
|
||||||
s = sym_push2(&define_stack, varg | SYM_FIELD, is_vaargs, 0);
|
s = sym_push2(&define_stack, varg | SYM_FIELD, is_vaargs, 0);
|
||||||
*ps = s;
|
*ps = s;
|
||||||
ps = &s->next;
|
ps = &s->next;
|
||||||
if (tok != ',')
|
if (tok != ',')
|
||||||
break;
|
continue;
|
||||||
next_nomacro();
|
next_nomacro();
|
||||||
}
|
}
|
||||||
if (tok == ')')
|
next_nomacro_spc();
|
||||||
next_nomacro_spc();
|
|
||||||
t = MACRO_FUNC;
|
t = MACRO_FUNC;
|
||||||
}
|
}
|
||||||
tok_str_new(&str);
|
tok_str_new(&str);
|
||||||
|
9
tests/tests2/68_macro_concat.c
Normal file
9
tests/tests2/68_macro_concat.c
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#define hexCh(c (c >= 10 ? 'a' + c - 10 : '0' + c)
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int c = 0xa;
|
||||||
|
printf("hex: %c\n", hexCh(c));
|
||||||
|
return 0;
|
||||||
|
}
|
1
tests/tests2/68_macro_concat.expect
Normal file
1
tests/tests2/68_macro_concat.expect
Normal file
@ -0,0 +1 @@
|
|||||||
|
68_macro_concat.c:2: error: '(' may not appear in parameter list
|
9
tests/tests2/69_macro_concat.c
Normal file
9
tests/tests2/69_macro_concat.c
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#define hexCh(c/3) (c >= 10 ? 'a' + c - 10 : '0' + c)
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int c = 0xa;
|
||||||
|
printf("hex: %c\n", hexCh(c));
|
||||||
|
return 0;
|
||||||
|
}
|
1
tests/tests2/69_macro_concat.expect
Normal file
1
tests/tests2/69_macro_concat.expect
Normal file
@ -0,0 +1 @@
|
|||||||
|
69_macro_concat.c:2: error: '/' may not appear in parameter list
|
@ -82,7 +82,9 @@ TESTS = \
|
|||||||
64_macro_nesting.test \
|
64_macro_nesting.test \
|
||||||
65_macro_concat_start.test \
|
65_macro_concat_start.test \
|
||||||
66_macro_concat_end.test \
|
66_macro_concat_end.test \
|
||||||
67_macro_concat.test
|
67_macro_concat.test \
|
||||||
|
68_macro_concat.test \
|
||||||
|
69_macro_concat.test
|
||||||
|
|
||||||
# 34_array_assignment.test -- array assignment is not in C standard
|
# 34_array_assignment.test -- array assignment is not in C standard
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user