This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: cpplib bug fix (macro expansion)
- To: Zack Weinberg <zack at rabi dot columbia dot edu>
- Subject: Re: cpplib bug fix (macro expansion)
- From: Dave Brolley <brolley at cygnus dot com>
- Date: Thu, 08 Oct 1998 14:31:02 -0400
- CC: egcs-patches at cygnus dot com
- Organization: Cygnus Solutions Canada Ltd
- References: <199810081625.MAA06969@blastula.phys.columbia.edu>
Zack Weinberg wrote:
> collect_expansion is commented above:
>
> /* ...
> Note that comments, backslash-newlines, and leading white space
> have already been deleted from the argument. */
>
> A comment *can* appear if -traditional, but it gets turned into a
> token paster.
It's fairly easy to generate a comment with a macro if -traditional that does
not get turned into a token paster. Simply leave white space around it.
#define COMMENT(x) M /x a comment x/ (1)
#define M(a) a
COMMENT(*)
In -traditional, this should expand to 1. I don't think your patch allows for
this.
> An un-backslashed newline can't get to
> collect_expansion because copy_rest_of_line will have stopped there.
Maybe true, but cpp_skip_hspace handles backslash-newline where your patch does
not. Also there are some kind of @ escapes which cpp-skip-hspace takes care of.
> So the only way to get a hard newline into a macro definition is with
> -D. Do you think this case is worth worrying about?
Try it. If it breaks, then it's worth worrying about :-)
Overall, I think it's safer to keep using cpp_skip_hspace, then to try and guess
what cases could arise. In my experience, whenever I play that game, I lose
because of some case I didn't know about.
Dave