This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: yet another cpplib bug fix
- To: Zack Weinberg <zack at rabi dot columbia dot edu>
- Subject: Re: yet another cpplib bug fix
- From: Dave Brolley <brolley at cygnus dot com>
- Date: Tue, 29 Sep 1998 17:51:07 -0400
- CC: egcs-patches at cygnus dot com
- Organization: Cygnus Solutions Canada Ltd
- References: <199809272034.QAA16335@rabi.phys.columbia.edu>
Pending your answer to my question about the @ and white space markers on your
previous patch, this looks OK to me.
Dave
Zack Weinberg wrote:
> This patch fixes the following bug:
>
> #define P(a,b) P1(a,b)
> #define P1(a,b) a##b
>
> #define ONCE(x, y) (x ?: x = y())
> #define PREFIX
>
> ONCE(memo, P(PREFIX, init))
>
> preprocesses to
>
> (memo ?: memo = @nit())
>
> The cause is an off by one error in macroexpand. (N.B.: This patch
> must be applied over the other two cpplib bugfixes I've posted.)
>
> See egcs-bugs for a full testcase.
>
> zw
>
> 1998-09-27 16:31 -0400 Zack Weinberg <zack@rabi.phys.columbia.edu>
>
> * cpplib.c (macroexpand): Correct off-by-one in reverse
> scanning of @ escapes.
>
> --- cpplib.c.bug3 Sun Sep 27 14:19:34 1998
> +++ cpplib.c Sun Sep 27 16:26:07 1998
> @@ -2888,8 +2888,8 @@
> /* If whitespace is preceded by an odd number
> of `@' signs, the last `@' was a whitespace
> marker; drop it too. */
> - while (p2 != p1 && p2[-1] == '@') p2--;
> - if ((l1 - 1 - p2) & 1)
> + while (p2 != p1 && p2[0] == '@') p2--;
> + if ((l1 - p2) & 1)
> l1--;
> break;
> }
> @@ -2899,8 +2899,8 @@
> /* If a `-' is preceded by an odd number of
> `@' signs then it and the last `@' are
> a no-reexpansion marker. */
> - while (p2 != p1 && p2[-1] == '@') p2--;
> - if ((l1 - 1 - p2) & 1)
> + while (p2 != p1 && p2[0] == '@') p2--;
> + if ((l1 - p2) & 1)
> l1 -= 2;
> else
> break;