This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Serious error-causing change in new CPP's -traditional behavior
On Thu, May 11, 2000 at 07:15:38AM +0900, Neil Booth wrote:
> Zack Weinberg wrote:-
>
> > A marginally better stupid game:
> >
> > #define IMMED(n) # ##n
> > #define foo() mov r0, IMMED(5)
>
> Or I could just get the lexer to drop all CPP_HASH tokens that are not
> the first token (so we still allow directives) if the assembler option
> is true?
No! That would have the effect of deleting every # from the output,
which is definitely not what Richard wants.
What I believe he wants is more along the lines of this patch.
Richard, care to give it a spin?
zw
===================================================================
Index: cpphash.c
--- cpphash.c 2000/05/10 19:11:02 1.87
+++ cpphash.c 2000/05/10 22:54:41
@@ -639,7 +639,22 @@ collect_funlike_expansion (pfile, list,
default:
norm:
if (last_token == STRIZE)
- cpp_error (pfile, "# is not followed by a macro argument name");
+ {
+ /* This is a mandatory diagnostic (6.10.3.2 para 1), but
+ in assembly language # may have some other
+ significance we don't know about, so suppress the
+ warning. */
+ if (! CPP_OPTION (pfile, lang_asm))
+ cpp_warning (pfile,
+ "# is not followed by a macro argument name");
+ if (TOK_PREV_WHITE (list, i))
+ CPP_ADJUST_WRITTEN (pfile, -1);
+ if (TOK_PREV_WHITE (list, i-1))
+ CPP_PUTC (pfile, ' ');
+ CPP_PUTC (pfile, '#');
+ if (TOK_PREV_WHITE (list, i))
+ CPP_PUTC (pfile, ' ');
+ }
CPP_PUTS (pfile, tok, len);
last_token = NORM;
}