tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Preprocessor bug prevents macro expansion


From: Alexandre Becoulet
Subject: Re: [Tinycc-devel] Preprocessor bug prevents macro expansion
Date: Fri, 29 Jan 2010 23:15:25 +0100
User-agent: KMail/1.12.4 (Linux/2.6.32-ARCH; KDE/4.3.4; x86_64; ; )

On Friday 29 January 2010 18:07:11 grischka wrote:

> > This should expand to XYZ (tryed with gcc, clang, intel and sun) but tcc
> > preprocessor expands to CONCAT(X, Y, Z).

> Yes, there are bugs.  Here is another one:

While comparing the current code with the standard I discovered some other 
bugs.

This example given in the C99 standard doesn't work either:

#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";

Expands to char p[] = "x y" with tcc.

Current implementation relies on a single nested tokens list to prevent 
recursive expansion. It appears some bugs can not be fixed without storing some 
context for each expanded token.

While trying to feed tcc with output from the GNU preprocessor I fixed this 
trivial bug:

--- a/tccpp.c
+++ b/tccpp.c
@@ -1620,7 +1620,7 @@ include_done:
         pragma_parse(s1);
         break;
     default:
-        if (tok == TOK_LINEFEED || tok == '!' || tok == TOK_CINT) {
+        if (tok == TOK_LINEFEED || tok == '!' || tok == TOK_PPNUM) {
             /* '!' is ignored to allow C scripts. numbers are ignored
                to emulate cpp behaviour */
         } else {

-- 
Alexandre




reply via email to

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