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


_______________________________________________
Tinycc-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to