This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: cpplib bug fix (macro expansion)




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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]