diff options
author | Zack Weinberg <zack@wolery.cumb.org> | 2000-05-19 17:43:38 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2000-05-19 17:43:38 +0000 |
commit | 021c89ed68c151c45021fccf1bb5338ee817314c (patch) | |
tree | e2cba00ae190dd65b7a62f9ca7a997e8a14fee72 | |
parent | b4c40d3c2c3711a0037162236fe293df52201e29 (diff) | |
download | gcc-021c89ed68c151c45021fccf1bb5338ee817314c.zip gcc-021c89ed68c151c45021fccf1bb5338ee817314c.tar.gz gcc-021c89ed68c151c45021fccf1bb5338ee817314c.tar.bz2 |
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
-rw-r--r-- | gcc/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cpphash.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/20000519-1.c | 10 |
3 files changed, 16 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 87308c1..668a377 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,8 @@ 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. * cpplib.c (do_unassert): Put the list to compare against on the stack. diff --git a/gcc/cpphash.c b/gcc/cpphash.c index 3eb7d1a..39c9735 100644 --- a/gcc/cpphash.c +++ b/gcc/cpphash.c @@ -1578,7 +1578,7 @@ funlike_macroexpand (pfile, hp, args) { /* Arg is concatenated before: delete leading whitespace, whitespace markers, and no-reexpansion markers. */ - while (p1 != l1) + while (p1 < l1) { if (is_space(p1[0])) p1++; @@ -1592,7 +1592,7 @@ funlike_macroexpand (pfile, hp, args) { /* Arg is concatenated after: delete trailing whitespace, whitespace markers, and no-reexpansion markers. */ - while (p1 != l1) + while (p1 < l1) { if (is_space(l1[-1])) l1--; @@ -1612,7 +1612,7 @@ funlike_macroexpand (pfile, hp, args) /* Delete any no-reexpansion marker that precedes 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; memcpy (xbuf + totlen, p1, l1 - p1); diff --git a/gcc/testsuite/gcc.dg/20000519-1.c b/gcc/testsuite/gcc.dg/20000519-1.c new file mode 100644 index 0000000..82ab3a2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20000519-1.c @@ -0,0 +1,10 @@ +/* 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 |