aboutsummaryrefslogtreecommitdiff
path: root/libcpp/lex.cc
diff options
context:
space:
mode:
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--;
}
}