Skip to content

Commit

Permalink
Small preprocessor fix
Browse files Browse the repository at this point in the history
Set BOL flag for code like:
  #define tcc_test()
  #if 1
  tcc_test
  #endif
  • Loading branch information
hermantb committed Oct 17, 2022
1 parent 79a8229 commit 878fccc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tccpp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3338,6 +3338,8 @@ static int macro_subst_tok(
for (i = 0; i < ws_str.len; i++)
tok_str_add(tok_str, ws_str.str[i]);
}
if (ws_str.len && ws_str.str[ws_str.len - 1] == '\n')
tok_flags |= TOK_FLAG_BOL;
tok_str_free_str(ws_str.str);
return 0;
} else {
Expand Down
9 changes: 9 additions & 0 deletions tests/tcctest.c
Original file line number Diff line number Diff line change
Expand Up @@ -4273,11 +4273,14 @@ void func_arg_test(void)
/* # define ACCEPT_LF_IN_STRINGS */
#endif

#define tcc_test()

/* keep this as the last test because GCC messes up line-numbers
with the ^L^K^M characters below */
void whitespace_test(void)
{
char *str;
int tcc_test = 1;

#if 1
pri\
Expand Down Expand Up @@ -4326,6 +4329,12 @@ ntf("min=%d\n", 4);
063\\
n 456\"\n");

printf ("%d\n",
#if 1
tcc_test
#endif
);

}

#define RUN(test) puts("---- " #test " ----"), test(), puts("")
Expand Down

0 comments on commit 878fccc

Please sign in to comment.