tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] pp bug


From: Pip Cet
Subject: Re: [Tinycc-devel] pp bug
Date: Fri, 1 May 2015 18:15:30 +0000

Ooh, those are excellent. Thanks for finding them!

Here's a preliminary patch that should fix all but tests 1 and 3,
which I'm still working on. Needs more testing and cleanup and all
that, but it would be great if someone could verify that the other
tests are indeed fixed by the patch.

> /* ---- TEST 1 ---------------------------------- */
> #define hash_hash # ## #
> #define mkstr(a) # a
> #define in_between(a) mkstr(a)
> #define join(c, d) in_between(c hash_hash d)
> char p[] = join(x, y);  // equivalent to
>                         // char p[] = "x ## y";
> /* --- EXPECT 1 --------------------------------- */
> char p[] = "x ## y";

This one's difficult. It seems we stringify in the wrong place, or
places. Closely related to test 3.

> /* ---- TEST 2 ---------------------------------- */
> #define x 3
> #define f(a) f(x * (a))
> #undef x
> #define x 2
> #define g f
> #define z z[0]
> #define h g(~
> #define m(a) a(w)
> #define w 0,1
> #define t(a) a
> #define p() int
> #define q(x) x
> #define r(x,y) x ## y
> #define str(x) # x
> f(y+1) + f(f(z)) % t(t(g)(0) + t)(1);
> g(x+(3,4)-w) | h 5) & m
> (f)^m(m);
> p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) };
> char c[2][6] = { str(hello), str() };
> /*
>  * 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);
>  * int i[] = { 1, 23, 4, 5, };
>  * char c[2][6] = { "hello", "" };
>  */

fixed this one, though the fix isn't pretty and leaks memory at present.

(will get back to test 3 later)

> /* ---- TEST 5 ---------------------------------- */
> #define t(x,y,z) x ## y ## z
> int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,),
>         t(10,,), t(,11,), t(,,12), t(,,) };

This one appears to be fixed by my other patches.

> /* ---- TEST 7 ---------------------------------- */
> #define a() YES
> #define b() a
> b()
> b()()
> /* --- EXPECT 7 --------------------------------- */
> a
> YES

Fixed this one. Actually found a bug in my previous patch, so that's great.

The rest, I think, already are passing?

Attachment: tcc-macro-005.diff
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]