diff options
| author | seyko <seyko2@gmail.com> | 2016-05-01 05:43:57 +0300 |
|---|---|---|
| committer | seyko <seyko2@gmail.com> | 2016-05-01 05:43:57 +0300 |
| commit | a1c139063b9157c804fd76eedb6a8060726fe0d5 (patch) | |
| tree | 59ccd96c58dbe63c9244fdf7d957a044a4df5ef9 /tests/pp | |
| parent | 256078933c8152038fd0d4fbff1d92b3bb3a14a3 (diff) | |
| download | tinycc-a1c139063b9157c804fd76eedb6a8060726fe0d5.tar.gz tinycc-a1c139063b9157c804fd76eedb6a8060726fe0d5.tar.bz2 | |
output space after TOK_PPNUM which followed by '+' or '-'
* correct -E output for the case ++ + ++ concatenation
do this only for expanded from macro string
and only when tcc_state->output_type == TCC_OUTPUT_PREPROCESS
Diffstat (limited to 'tests/pp')
| -rw-r--r-- | tests/pp/02.expect | 5 | ||||
| -rw-r--r-- | tests/pp/14.c | 11 | ||||
| -rw-r--r-- | tests/pp/14.expect | 8 | ||||
| -rw-r--r-- | tests/pp/15.c | 21 | ||||
| -rw-r--r-- | tests/pp/15.expect | 6 | ||||
| -rw-r--r-- | tests/pp/Makefile | 6 |
6 files changed, 52 insertions, 5 deletions
diff --git a/tests/pp/02.expect b/tests/pp/02.expect index 16f42ae..625c80b 100644 --- a/tests/pp/02.expect +++ b/tests/pp/02.expect @@ -1,5 +1,6 @@ f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1); -f(2 * (2+(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1); +f(2 * (2 +(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1); + char c[2][6] = { "hello", "" }; f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1); -f(2 * (2+(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1); +f(2 * (2 +(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1); diff --git a/tests/pp/14.c b/tests/pp/14.c new file mode 100644 index 0000000..8611479 --- /dev/null +++ b/tests/pp/14.c @@ -0,0 +1,11 @@ +extern int printf(const char *format, ...); +#define P ++ +#define n(x) x + +int main(void) +{ + int a = 0, b = -1; + int i1 = a P+P b; + printf("i1 = %d\n", i1); + return n(0x1e)n(-1); +} diff --git a/tests/pp/14.expect b/tests/pp/14.expect new file mode 100644 index 0000000..138f97b --- /dev/null +++ b/tests/pp/14.expect @@ -0,0 +1,8 @@ +extern int printf(const char *format, ...); +int main(void) +{ + int a = 0, b = -1; + int i1 = a +++ ++ b; + printf("i1 = %d\n", i1); + return 0x1e -1; +} diff --git a/tests/pp/15.c b/tests/pp/15.c new file mode 100644 index 0000000..28a12bd --- /dev/null +++ b/tests/pp/15.c @@ -0,0 +1,21 @@ +#define Y(x) Z(x) +#define X Y +X(1) +X(X(1)) +X(X(X(X(X(1))))) + +#define A B +#define B A +return A + B; + +#undef A +#undef B + +#define A B+1 +#define B A +return A + B; + +#define A1 B1+1 +#define B1 C1+2 +#define C1 A1+3 +return A1 + B1; diff --git a/tests/pp/15.expect b/tests/pp/15.expect new file mode 100644 index 0000000..7ccee4a --- /dev/null +++ b/tests/pp/15.expect @@ -0,0 +1,6 @@ +Z(1) +Z(Z(1)) +Z(Z(Z(Z(Z(1))))) +return A + B; +return A+1 + B+1; +return A1+3 +2 +1 + B1+1 +3 +2; diff --git a/tests/pp/Makefile b/tests/pp/Makefile index 5694ebb..7f42a3e 100644 --- a/tests/pp/Makefile +++ b/tests/pp/Makefile @@ -6,17 +6,17 @@ TCC = ../../tcc TESTS = $(patsubst %.c,%.test,$(wildcard *.c)) TESTS += $(patsubst %.S,%.test,$(wildcard *.S)) -all test : $(TESTS) +all test : $(sort $(TESTS)) %.test: %.c %.expect @echo PPTest $* ... - @$(TCC) -E -P $< >$*.output 2>&1 ; \ + -@$(TCC) -E -P $< >$*.output 2>&1 ; \ diff -Nu -b -B -I "^#" $(EXTRA_DIFF_OPTS) $*.expect $*.output \ && rm -f $*.output %.test: %.S %.expect @echo PPTest $* ... - @$(TCC) -E -P $< >$*.output 2>&1 ; \ + -@$(TCC) -E -P $< >$*.output 2>&1 ; \ diff -Nu -b -B -I "^#" $(EXTRA_DIFF_OPTS) $*.expect $*.output \ && rm -f $*.output |
