aboutsummaryrefslogtreecommitdiff
path: root/libcpp/lex.cc
diff options
context:
space:
mode:
authorJerry DeLisle <jvdelisle@gcc.gnu.org>2025-09-02 15:58:26 -0700
committerJerry DeLisle <jvdelisle@gcc.gnu.org>2025-09-02 15:58:26 -0700
commit071b4126c613881f4cb25b4e5c39032964827f88 (patch)
tree7ed805786566918630d1d617b1ed8f7310f5fd8e /libcpp/lex.cc
parent845d23f3ea08ba873197c275a8857eee7edad996 (diff)
parentcaa1c2f42691d68af4d894a5c3e700ecd2dba080 (diff)
downloadgcc-devel/gfortran-test.zip
gcc-devel/gfortran-test.tar.gz
gcc-devel/gfortran-test.tar.bz2
Merge branch 'master' into gfortran-testdevel/gfortran-test
Diffstat (limited to 'libcpp/lex.cc')
-rw-r--r--libcpp/lex.cc30
1 files changed, 14 insertions, 16 deletions
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--;
}
}