aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog19
-rw-r--r--libcpp/lex.cc30
-rw-r--r--libcpp/macro.cc7
3 files changed, 38 insertions, 18 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index ca67a64..7deda4b 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,22 @@
+2025-08-05 Jakub Jelinek <jakub@redhat.com>
+
+ PR preprocessor/120778
+ * macro.cc (paste_tokens): Use %< and %> instead of \" in
+ diagnostics around %.*s.
+
+2025-08-04 Jakub Jelinek <jakub@redhat.com>
+
+ PR preprocessor/120778
+ * macro.cc (stringify_arg): For C++26 emit a pedarn instead of warning
+ for \ at the end of stringification.
+
+2025-08-03 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/120845
+ * lex.cc (cpp_maybe_module_directive): Move eol variable declaration
+ to the start of the function, initialize to false and only set it to
+ peek->type == CPP_PRAGMA_EOL in the not_module case. Formatting fix.
+
2025-07-30 Jakub Jelinek <jakub@redhat.com>
PR c++/120778
diff --git a/libcpp/lex.cc b/libcpp/lex.cc
index e7705a6..2ba9d58 100644
--- a/libcpp/lex.cc
+++ b/libcpp/lex.cc
@@ -3505,6 +3505,7 @@ cpp_maybe_module_directive (cpp_reader *pfile, cpp_token *result)
cpp_token *keyword = peek;
cpp_hashnode *(&n_modules)[spec_nodes::M_HWM][2] = pfile->spec_nodes.n_modules;
int header_count = 0;
+ bool eol = false;
/* Make sure the incoming state is as we expect it. This way we
can restore it using constants. */
@@ -3564,10 +3565,10 @@ cpp_maybe_module_directive (cpp_reader *pfile, cpp_token *result)
tokens. C++ keywords are not yet relevant. */
if (peek->type == CPP_NAME
|| peek->type == CPP_COLON
- || (header_count
- ? (peek->type == CPP_LESS
- || (peek->type == CPP_STRING && peek->val.str.text[0] != 'R')
- || peek->type == CPP_HEADER_NAME)
+ || (header_count
+ ? (peek->type == CPP_LESS
+ || (peek->type == CPP_STRING && peek->val.str.text[0] != 'R')
+ || peek->type == CPP_HEADER_NAME)
: peek->type == CPP_SEMICOLON))
{
pfile->state.pragma_allow_expansion = !CPP_OPTION (pfile, preprocessed);
@@ -3689,22 +3690,19 @@ cpp_maybe_module_directive (cpp_reader *pfile, cpp_token *result)
pfile->state.in_deferred_pragma = false;
/* Do not let this remain on. */
pfile->state.angled_headers = false;
+ /* If we saw EOL, we should drop it, because this isn't a module
+ control-line after all. */
+ eol = peek->type == CPP_PRAGMA_EOL;
}
/* In either case we want to backup the peeked tokens. */
- if (backup)
+ if (backup && (!eol || backup > 1))
{
- /* If we saw EOL, we should drop it, because this isn't a module
- control-line after all. */
- bool eol = peek->type == CPP_PRAGMA_EOL;
- if (!eol || backup > 1)
- {
- /* Put put the peeked tokens back */
- _cpp_backup_tokens_direct (pfile, backup);
- /* But if the last one was an EOL, forget it. */
- if (eol)
- pfile->lookaheads--;
- }
+ /* Put the peeked tokens back. */
+ _cpp_backup_tokens_direct (pfile, backup);
+ /* But if the last one was an EOL in the not_module case, forget it. */
+ if (eol)
+ pfile->lookaheads--;
}
}
diff --git a/libcpp/macro.cc b/libcpp/macro.cc
index be25710..158c821 100644
--- a/libcpp/macro.cc
+++ b/libcpp/macro.cc
@@ -1003,7 +1003,10 @@ stringify_arg (cpp_reader *pfile, const cpp_token **first, unsigned int count)
/* Ignore the final \ of invalid string literals. */
if (backslash_count & 1)
{
- cpp_error (pfile, CPP_DL_WARNING,
+ cpp_error (pfile,
+ CPP_OPTION (pfile, cplusplus)
+ && CPP_OPTION (pfile, lang) >= CLK_GNUCXX26
+ ? CPP_DL_PEDWARN : CPP_DL_WARNING,
"invalid string literal, ignoring final %<\\%>");
dest--;
}
@@ -1068,7 +1071,7 @@ paste_tokens (cpp_reader *pfile, location_t location,
/* Mandatory error for all apart from assembler. */
if (CPP_OPTION (pfile, lang) != CLK_ASM)
cpp_error_with_line (pfile, CPP_DL_ERROR, location, 0,
- "pasting \"%.*s\" and \"%.*s\" does not give "
+ "pasting %<%.*s%> and %<%.*s%> does not give "
"a valid preprocessing token",
(int) (lhsend - buf), buf,
(int) (end - rhsstart), rhsstart);