aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2020-05-19 06:11:22 -0700
committerGiuliano Belinassi <giuliano.belinassi@usp.br>2020-08-17 13:03:48 -0300
commitd72d2fc9a54da7ef24bd07b0748b7d87035b99a4 (patch)
treee26fbf9c46d075b5d6e06f2eeac214d4e30c8e9b /gcc
parent8b10d7e3987315ddeccb89427099744c6a461790 (diff)
downloadgcc-d72d2fc9a54da7ef24bd07b0748b7d87035b99a4.zip
gcc-d72d2fc9a54da7ef24bd07b0748b7d87035b99a4.tar.gz
gcc-d72d2fc9a54da7ef24bd07b0748b7d87035b99a4.tar.bz2
preprocessor: Fix ICE with EOF in macro args [pr95182]
This was another latent case of us losing an EOF token, but succeeding anyway. Since my patch to make us pay more attention to EOFs it came to light. We also need to keep the EOF if we fall off the end of the main file. Forced includes look like regular nested includes at this point. PR preprocessor/95182 libcpp/ * macro.c (collect_args): Preserve EOFif we fell out of the main file. (cpp_get_token_1): Reformat a couple of short lines.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/c-c++-common/cpp/eof-1.c7
-rw-r--r--gcc/testsuite/c-c++-common/cpp/eof-2.c8
-rw-r--r--gcc/testsuite/c-c++-common/cpp/eof-2.h4
-rw-r--r--gcc/testsuite/c-c++-common/cpp/eof-3.c8
4 files changed, 27 insertions, 0 deletions
diff --git a/gcc/testsuite/c-c++-common/cpp/eof-1.c b/gcc/testsuite/c-c++-common/cpp/eof-1.c
new file mode 100644
index 0000000..0a06f09
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cpp/eof-1.c
@@ -0,0 +1,7 @@
+/* PR preprocess/95183 */
+
+/* { dg-do preprocess } */
+
+#define f(x) x
+
+f( /* { dg-error "-:unterminated" "unterminated macro" } */
diff --git a/gcc/testsuite/c-c++-common/cpp/eof-2.c b/gcc/testsuite/c-c++-common/cpp/eof-2.c
new file mode 100644
index 0000000..3a4af7f
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cpp/eof-2.c
@@ -0,0 +1,8 @@
+/* PR preprocess/95183 */
+
+/* { dg-do preprocess } */
+
+#define f(x) x
+
+#include "eof-2.h"
+ /* { dg-regexp {[^\n]*eof-2.h:4: error: unterminated argument list invoking macro "f"\n} } */
diff --git a/gcc/testsuite/c-c++-common/cpp/eof-2.h b/gcc/testsuite/c-c++-common/cpp/eof-2.h
new file mode 100644
index 0000000..48ad857
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cpp/eof-2.h
@@ -0,0 +1,4 @@
+
+#define f(x) x
+
+f( /* Error here */
diff --git a/gcc/testsuite/c-c++-common/cpp/eof-3.c b/gcc/testsuite/c-c++-common/cpp/eof-3.c
new file mode 100644
index 0000000..316918e
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cpp/eof-3.c
@@ -0,0 +1,8 @@
+/* PR preprocess/95183 */
+
+/* { dg-do preprocess } */
+/* { dg-additional-options "-include $srcdir/c-c++-common/cpp/eof-2.h" } */
+
+ /* { dg-regexp {[^\n]*eof-2.h:4: error: unterminated argument list invoking macro "f"\n} } */
+
+token )