mirror of
https://github.com/frida/tinycc
synced 2025-01-13 23:19:18 +03:00
1 macro_push and macro_pop work I made a mistake, no matter the definition does not define can be macro_push.
And the modified tcctest.c test 2, pack: in the compiler under the mode of s1->ppfp, I have no clear ideas1->ppfp Some advice thank you Roy to me.This patch, I hope I can pass the Roy test
This commit is contained in:
parent
276553c6b2
commit
196c999515
1
tcc.h
1
tcc.h
@ -1132,7 +1132,6 @@ ST_DATA TokenSym **table_ident;
|
||||
returned at eof */
|
||||
#define PARSE_FLAG_ASM_COMMENTS 0x0008 /* '#' can be used for line comment */
|
||||
#define PARSE_FLAG_SPACES 0x0010 /* next() returns space tokens (for -E) */
|
||||
#define PARSE_FLAG_PACK 0x0020 /* #pragma pack */
|
||||
|
||||
ST_FUNC TokenSym *tok_alloc(const char *str, int len);
|
||||
ST_FUNC char *get_tok_str(int v, CValue *cv);
|
||||
|
27
tccpp.c
27
tccpp.c
@ -1627,7 +1627,7 @@ skip:
|
||||
break;
|
||||
case TOK_PRAGMA:
|
||||
next();
|
||||
if (tok == TOK_pack && parse_flags & PARSE_FLAG_PACK) {
|
||||
if (tok == TOK_pack && s1->output_type != TCC_OUTPUT_PREPROCESS) {
|
||||
/*
|
||||
This may be:
|
||||
#pragma pack(1) // set
|
||||
@ -1736,32 +1736,29 @@ pack_error:
|
||||
def = &ts->sym_define;
|
||||
if(t == TOK_PUSH_MACRO){
|
||||
void *tmp = def->data[def->off];
|
||||
if(tmp){
|
||||
def->off++;
|
||||
if(def->off >= def->size){
|
||||
int size = def->size;
|
||||
size *= 2;
|
||||
if (size > MACRO_STACK_SIZE)
|
||||
tcc_error("stack full");
|
||||
def->data = tcc_realloc(def->data, size*sizeof(Sym*));
|
||||
def->size = size;
|
||||
}
|
||||
def->data[def->off] = tmp;
|
||||
def->off++;
|
||||
if(def->off >= def->size){
|
||||
int size = def->size;
|
||||
size *= 2;
|
||||
if (size > MACRO_STACK_SIZE)
|
||||
tcc_error("stack full");
|
||||
def->data = tcc_realloc(def->data, size*sizeof(Sym*));
|
||||
def->size = size;
|
||||
}
|
||||
def->data[def->off] = tmp;
|
||||
}else{
|
||||
if(def->off){
|
||||
--def->off;
|
||||
}else{
|
||||
tcc_warning("stack empty");
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
}else if(s1->output_type == TCC_OUTPUT_PREPROCESS){
|
||||
fputs("#pragma ", s1->ppfp);
|
||||
while (tok != TOK_LINEFEED){
|
||||
fputs(get_tok_str(tok, &tokc), s1->ppfp);
|
||||
next();
|
||||
}
|
||||
fputs("\n", s1->ppfp);
|
||||
goto the_end;
|
||||
}
|
||||
break;
|
||||
|
@ -379,34 +379,46 @@ comment
|
||||
/* And again when the name and parenthes are separated by a
|
||||
comment. */
|
||||
TEST2 /* the comment */ ();
|
||||
|
||||
/* macro_push and macro_pop test */
|
||||
#define MACRO_TEST "macro_test1\n"
|
||||
#pragma push_macro("MACRO_TEST")
|
||||
printf(MACRO_TEST);
|
||||
#undef MACRO_TEST
|
||||
#ifdef MACRO_TEST
|
||||
printf("define MACRO_TEST\n");
|
||||
#else
|
||||
printf("undef MACRO_TEST\n");
|
||||
#endif
|
||||
|
||||
#define MACRO_TEST "macro_test2\n"
|
||||
#pragma push_macro("MACRO_TEST")
|
||||
printf(MACRO_TEST);
|
||||
#undef MACRO_TEST
|
||||
|
||||
#define MACRO_TEST "macro_test3\n"
|
||||
#define MACRO_TEST
|
||||
#pragma push_macro("MACRO_TEST")
|
||||
printf(MACRO_TEST);
|
||||
#undef MACRO_TEST
|
||||
|
||||
#define MACRO_TEST "macro_test4\n"
|
||||
printf(MACRO_TEST);
|
||||
#undef MACRO_TEST
|
||||
#pragma push_macro("MACRO_TEST")
|
||||
|
||||
#pragma pop_macro("MACRO_TEST")
|
||||
printf(MACRO_TEST);
|
||||
#ifdef MACRO_TEST
|
||||
printf("define MACRO_TEST\n");
|
||||
#else
|
||||
printf("undef MACRO_TEST\n");
|
||||
#endif
|
||||
|
||||
#pragma pop_macro("MACRO_TEST")
|
||||
printf(MACRO_TEST);
|
||||
#ifdef MACRO_TEST
|
||||
printf("define MACRO_TEST\n");
|
||||
#else
|
||||
printf("undef MACRO_TEST\n");
|
||||
#endif
|
||||
|
||||
#pragma pop_macro("MACRO_TEST")
|
||||
printf(MACRO_TEST);
|
||||
#ifdef MACRO_TEST
|
||||
printf("define MACRO_TEST\n");
|
||||
#else
|
||||
printf("undef MACRO_TEST\n");
|
||||
#endif
|
||||
|
||||
/* pack test */
|
||||
#pragma pack(push,8)
|
||||
#pragma pack(pop)
|
||||
|
||||
/* gcc does not support
|
||||
#define MACRO_TEST_MACRO "MACRO_TEST"
|
||||
#pragma push_macro(MACRO_TEST_MACRO)
|
||||
|
Loading…
Reference in New Issue
Block a user