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: Sat, 2 May 2015 16:16:12 +0000

I've applied some of the changes to mob, and I'm attaching a diff with
the remaining changes. Feel free to revert some or all of those if you
think they need further discussion or shouldn't go in at all.

I'm not sure I have handling of placeholders and GNU commas right; the
problem is I can't compare to gcc as gcc has stopped supporting them
in most cases.



On Sat, May 2, 2015 at 11:50 AM, Pip Cet <address@hidden> wrote:
> I think everything is working now, with one exception that I think is fine:
>
> #define STRINGIFY2(x) #x
> #define STRINGIFY(x) STRINGIFY2(x)
> #define a \4
>
> int main (void)
> {
>   printf("%s\n", STRINGIFY(a));
> }
>
> produces "\004", not "\4". They're equivalent, though.
>
> I'd appreciate it very much if people found things that are still
> broken with this patch, though I have my suspicions about a few cases
> that I'm going to try reproducing and fixing next (and then the memory
> leak and various cleanups).
>
> Thanks again for finding the test cases!
>
> On Fri, May 1, 2015 at 6:15 PM, Pip Cet <address@hidden> wrote:
>> 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-008.diff
Description: Text document


reply via email to

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