aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2020-10-19 07:57:50 -0700
committerNathan Sidwell <nathan@acm.org>2020-10-19 08:00:41 -0700
commit5abe05b4331250b6a7798ce87c0a82adc2bd70f3 (patch)
treee0e0014c3fb9a8fdf77f99b7393dd0dd443f9a0d /gcc
parent8d31eb8f17fa17f63d46651af1c69fb8eca2d04a (diff)
downloadgcc-5abe05b4331250b6a7798ce87c0a82adc2bd70f3.zip
gcc-5abe05b4331250b6a7798ce87c0a82adc2bd70f3.tar.gz
gcc-5abe05b4331250b6a7798ce87c0a82adc2bd70f3.tar.bz2
preprocessor: Fix non-fn fn-like macro at EOF [PR97471]
We inject EOF tokens between macro argument lists, but had confused/stale logic in the non-fn invocation. Renamed the magic 'eof' token, as it's now only used for macro argument termination. Always rewind the non-OPEN_PAREN token. libcpp/ * internal.h (struct cpp_reader): Rename 'eof' field to 'endarg'. * init.c (cpp_create_reader): Adjust. * macro.c (collect_args): Use endarg for separator. Always rewind in the not-fn case. gcc/testsuite/ * c-c++-common/cpp/pr97471.c: New.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/c-c++-common/cpp/pr97471.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/testsuite/c-c++-common/cpp/pr97471.c b/gcc/testsuite/c-c++-common/cpp/pr97471.c
new file mode 100644
index 0000000..f1e512e
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cpp/pr97471.c
@@ -0,0 +1,10 @@
+/* PR preprocessor/97471 */
+/* { dg-do compile } */
+
+/* ICE with non-fn use of fn-like macro at EOF */
+
+#define a() b
+
+/* { dg-error "expected" "" { target c } .+2 } */
+/* { dg-error "does not name" "" { target c++ } .+1 } */
+a