aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2007-11-01 18:20:48 +0000
committerTom Tromey <tromey@gcc.gnu.org>2007-11-01 18:20:48 +0000
commitf373b44d282eca5e494f71ef2ad16f00b0ff1233 (patch)
treed2d010b50cd8299a7b0f4980f1321627be3431c2
parent233a722b41e85a05c88390bea6764e93a1bf92ea (diff)
downloadgcc-f373b44d282eca5e494f71ef2ad16f00b0ff1233.zip
gcc-f373b44d282eca5e494f71ef2ad16f00b0ff1233.tar.gz
gcc-f373b44d282eca5e494f71ef2ad16f00b0ff1233.tar.bz2
re PR preprocessor/30805 (Internal compiler error when using "x##,##__VA_ARGS__" in macro)
libcpp PR preprocessor/30805: * macro.c (paste_tokens): Handle padding token. (paste_tokens): Don't abort unless padding has PASTE_LEFT flag. gcc/testsuite PR preprocessor/30805: * gcc.dg/cpp/pr30805.c: New file. From-SVN: r129827
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/cpp/pr30805.c5
-rw-r--r--libcpp/ChangeLog6
-rw-r--r--libcpp/macro.c10
4 files changed, 23 insertions, 3 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8c56415..3d35ba0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2007-11-01 Tom Tromey <tromey@redhat.com>
+
+ PR preprocessor/30805:
+ * gcc.dg/cpp/pr30805.c: New file.
+
2007-11-01 Janis Johnson <janis187@us.ibm.com>
PR testsuite/25352
diff --git a/gcc/testsuite/gcc.dg/cpp/pr30805.c b/gcc/testsuite/gcc.dg/cpp/pr30805.c
new file mode 100644
index 0000000..4f56a76
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/pr30805.c
@@ -0,0 +1,5 @@
+/* PR preprocessor/30805 - ICE while token pasting. */
+/* { dg-do preprocess } */
+
+#define A(x,...) x##,##__VA_ARGS__
+A(1)
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index beed407..c7cfa17 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,9 @@
+2007-11-01 Tom Tromey <tromey@redhat.com>
+
+ PR preprocessor/30805:
+ * macro.c (paste_tokens): Handle padding token.
+ (paste_tokens): Don't abort unless padding has PASTE_LEFT flag.
+
2007-10-31 Tom Tromey <tromey@redhat.com>
PR preprocessor/30786:
diff --git a/libcpp/macro.c b/libcpp/macro.c
index 50bb34d..f3a4420 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -451,7 +451,9 @@ paste_tokens (cpp_reader *pfile, const cpp_token **plhs, const cpp_token *rhs)
false doesn't work, since we want to clear the PASTE_LEFT flag. */
if ((*plhs)->type == CPP_DIV && rhs->type != CPP_EQ)
*end++ = ' ';
- end = cpp_spell_token (pfile, rhs, end, false);
+ /* In one obscure case we might see padding here. */
+ if (rhs->type != CPP_PADDING)
+ end = cpp_spell_token (pfile, rhs, end, false);
*end = '\n';
cpp_push_buffer (pfile, buf, end - buf, /* from_stage3 */ true);
@@ -514,8 +516,10 @@ paste_all_tokens (cpp_reader *pfile, const cpp_token *lhs)
rhs = *FIRST (context).ptoken++;
if (rhs->type == CPP_PADDING)
- abort ();
-
+ {
+ if (rhs->flags & PASTE_LEFT)
+ abort ();
+ }
if (!paste_tokens (pfile, &lhs, rhs))
break;
}