summaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorLewis Hyatt <lhyatt@gmail.com>2024-10-14 17:59:46 -0400
committerLewis Hyatt <lhyatt@gcc.gnu.org>2024-11-25 13:36:09 -0500
commit9214e3fdf914dd2b687f13980c39ac2db7b1565f (patch)
tree1f9e8cc968f7256a28263652e38db981810d9263 /libcpp
parent4a63cc6de77481878ec31e1e6ac30e22c50b063a (diff)
libcpp: Fix ICE lexing invalid raw string in a deferred pragma [PR117118]
The PR shows that we ICE after lexing an invalid unterminated raw string, because lex_raw_string() pops the main buffer unexpectedly. Resolve by handling this case the same way as for other directives. libcpp/ChangeLog: PR preprocessor/117118 * lex.cc (lex_raw_string): Treat an unterminated raw string the same way for a deferred pragma as is done for other directives. gcc/testsuite/ChangeLog: PR preprocessor/117118 * c-c++-common/raw-string-directive-3.c: New test. * c-c++-common/raw-string-directive-4.c: New test.
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/lex.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/libcpp/lex.cc b/libcpp/lex.cc
index c9e44e6cccc..a6c97e35f44 100644
--- a/libcpp/lex.cc
+++ b/libcpp/lex.cc
@@ -2768,7 +2768,8 @@ lex_raw_string (cpp_reader *pfile, cpp_token *token, const uchar *base)
{
pos--;
pfile->buffer->cur = pos;
- if ((pfile->state.in_directive || pfile->state.parsing_args)
+ if ((pfile->state.in_directive || pfile->state.parsing_args
+ || pfile->state.in_deferred_pragma)
&& pfile->buffer->next_line >= pfile->buffer->rlimit)
{
cpp_error_with_line (pfile, CPP_DL_ERROR, token->src_loc, 0,