]> gcc.gnu.org Git - gcc.git/commitdiff
cpphash.c (funlike_macroexpand): Make sure not to walk p1 past l1 when deleting white...
authorZack Weinberg <zack@wolery.cumb.org>
Fri, 19 May 2000 17:43:38 +0000 (17:43 +0000)
committerZack Weinberg <zack@gcc.gnu.org>
Fri, 19 May 2000 17:43:38 +0000 (17:43 +0000)
* cpphash.c (funlike_macroexpand): Make sure not to walk p1
past l1 when deleting whitespace and markers.

From-SVN: r34027

gcc/ChangeLog
gcc/cpphash.c
gcc/testsuite/gcc.dg/20000519-1.c [new file with mode: 0644]

index 87308c1aba388c8dda609b819c1ab5a0ec14c715..668a377724a334f3b1af98db67ac04b7a8f0328c 100644 (file)
@@ -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.
index 3eb7d1a0e7a259e7e0baf42631a95964aa332e7f..39c97354499b29c90f730cd46a55b675b1785bd4 100644 (file)
@@ -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 (file)
index 0000000..82ab3a2
--- /dev/null
@@ -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
This page took 0.094395 seconds and 5 git commands to generate.