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: Thu, 30 Apr 2015 21:35:07 +0000

On Thu, Apr 30, 2015 at 8:03 PM, grischka <address@hidden> wrote:
> Pip Cet wrote:
>>
>> Does this fix it for you? Even if it doesn't, this should indicate
>> where the code is that goes wrong...
>
>
> Yep, just funny how long it did NOT go wrong...

Well, it happens exclusively when a macro expands recursively to
another macro and we hit EOB at the same time. I'm about to commit
some changes that make tcc read files one character at a time (when
debugging is enabled, of course), which might help find such bugs in
future...

>> ch = tcc_peekc_slow(file);
>
> as in ch = handle_eob();

I think peekc_slow indicates more precisely what we're doing—reading
the next character, whether or not we're at EOB.  handle_eob() sounds
like we're definitely at EOB, which we might not be. However, feel
free to change this if you disagree.

>
> One more, anyone ?
>
>     #define t(x,y,z) x ## y ## z
>
>     int main(int argc, char **argv)
>     {
>         return t(1,,) + t(,2,) + t(,,3);
>
>     }

Does C99 allow concatenating two empty tokens?

#define t(x,y) x ## y

void main(int argc, char **argv)
{
  return t(,);
}

also doesn't do what it probably should.

Here's a patch that makes things work by brute force, and it doesn't
appear to break any of the tests. However, it does make:

#define t(x,y) x ## y
#define A(x,y...) f(x,##y)

A(a,t(,))

produce f(,  ), with the extra comma. That's not really compatible
with A(a,) -> f(x), though GCC has stopped handling this case
specially (see http://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html),
so maybe we should as well... (A(a) still works).

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


reply via email to

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