Commit 021c89ed by Zack Weinberg Committed by Zack Weinberg

cpphash.c (funlike_macroexpand): Make sure not to walk p1 past l1 when deleting…

cpphash.c (funlike_macroexpand): Make sure not to walk p1 past l1 when deleting whitespace and markers.

	* cpphash.c (funlike_macroexpand): Make sure not to walk p1
	past l1 when deleting whitespace and markers.

From-SVN: r34027
parent b4c40d3c
2000-05-19 Zack Weinberg <zack@wolery.cumb.org> 2000-05-19 Zack Weinberg <zack@wolery.cumb.org>
* cpphash.c (funlike_macroexpand): Make sure not to walk p1
past l1 when deleting whitespace and markers.
* cpplex.c (_cpp_scan_until): Clear AUX field of tokens. * cpplex.c (_cpp_scan_until): Clear AUX field of tokens.
* cpplib.c (do_unassert): Put the list to compare against on * cpplib.c (do_unassert): Put the list to compare against on
the stack. the stack.
......
...@@ -1578,7 +1578,7 @@ funlike_macroexpand (pfile, hp, args) ...@@ -1578,7 +1578,7 @@ funlike_macroexpand (pfile, hp, args)
{ {
/* Arg is concatenated before: delete leading whitespace, /* Arg is concatenated before: delete leading whitespace,
whitespace markers, and no-reexpansion markers. */ whitespace markers, and no-reexpansion markers. */
while (p1 != l1) while (p1 < l1)
{ {
if (is_space(p1[0])) if (is_space(p1[0]))
p1++; p1++;
...@@ -1592,7 +1592,7 @@ funlike_macroexpand (pfile, hp, args) ...@@ -1592,7 +1592,7 @@ funlike_macroexpand (pfile, hp, args)
{ {
/* Arg is concatenated after: delete trailing whitespace, /* Arg is concatenated after: delete trailing whitespace,
whitespace markers, and no-reexpansion markers. */ whitespace markers, and no-reexpansion markers. */
while (p1 != l1) while (p1 < l1)
{ {
if (is_space(l1[-1])) if (is_space(l1[-1]))
l1--; l1--;
...@@ -1612,7 +1612,7 @@ funlike_macroexpand (pfile, hp, args) ...@@ -1612,7 +1612,7 @@ funlike_macroexpand (pfile, hp, args)
/* Delete any no-reexpansion marker that precedes /* Delete any no-reexpansion marker that precedes
an identifier at the beginning of the argument. */ an identifier at the beginning of the argument. */
if (p1[0] == '\r' && p1[1] == '-') if (p1 + 2 <= l1 && p1[0] == '\r' && p1[1] == '-')
p1 += 2; p1 += 2;
memcpy (xbuf + totlen, p1, l1 - p1); memcpy (xbuf + totlen, p1, l1 - p1);
......
/* Regression test for preprocessor crash.
Reported by Mathias Froehlich <frohlich@na.uni-tuebingen.de>. */
/* { dg-do preprocess } */
#define foo
#define __CAT__(a,b,c,d) a##b##c##d
#define CAT(a,b,c,d) __CAT__(a,b,c,d)
#define bar CAT(,foo,bar,)
bar
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment