aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog7
-rw-r--r--libcpp/macro.c23
2 files changed, 27 insertions, 3 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index e61700f..11c0773 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,10 @@
+2020-02-04 Jakub Jelinek <jakub@redhat.com>
+
+ PR preprocessor/93545
+ * macro.c (cpp_get_token_no_padding): New function.
+ (builtin_has_include): Use it instead of cpp_get_token. Don't check
+ SEEN_EOL.
+
2020-02-01 Andrew Burgess <andrew.burgess@embecosm.com>
* configure: Regenerate.
diff --git a/libcpp/macro.c b/libcpp/macro.c
index ec3f8b7..9f9f831 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -336,6 +336,22 @@ unsigned num_expanded_macros_counter = 0;
from macro expansion. */
unsigned num_macro_tokens_counter = 0;
+/* Wrapper around cpp_get_token to skip CPP_PADDING tokens
+ and not consume CPP_EOF. */
+static const cpp_token *
+cpp_get_token_no_padding (cpp_reader *pfile)
+{
+ for (;;)
+ {
+ const cpp_token *ret = cpp_peek_token (pfile, 0);
+ if (ret->type == CPP_EOF)
+ return ret;
+ ret = cpp_get_token (pfile);
+ if (ret->type != CPP_PADDING)
+ return ret;
+ }
+}
+
/* Handle meeting "__has_include" builtin macro. */
static int
@@ -344,10 +360,10 @@ builtin_has_include (cpp_reader *pfile, cpp_hashnode *op, bool has_next)
int result = 0;
pfile->state.angled_headers = true;
- const cpp_token *token = cpp_get_token (pfile);
+ const cpp_token *token = cpp_get_token_no_padding (pfile);
bool paren = token->type == CPP_OPEN_PAREN;
if (paren)
- token = cpp_get_token (pfile);
+ token = cpp_get_token_no_padding (pfile);
else
cpp_error (pfile, CPP_DL_ERROR,
"missing '(' before \"%s\" operand", NODE_NAME (op));
@@ -379,7 +395,8 @@ builtin_has_include (cpp_reader *pfile, cpp_hashnode *op, bool has_next)
XDELETEVEC (fname);
}
- if (paren && !SEEN_EOL () && cpp_get_token (pfile)->type != CPP_CLOSE_PAREN)
+ if (paren
+ && cpp_get_token_no_padding (pfile)->type != CPP_CLOSE_PAREN)
cpp_error (pfile, CPP_DL_ERROR,
"missing ')' after \"%s\" operand", NODE_NAME (op));