{
cp_token *token = lexer->next_token;
- gcc_assert (!lexer->in_pragma || token->type != CPP_PRAGMA_EOL);
-
do
{
gcc_assert (token->type != CPP_EOF);
case CPP_PRAGMA:
/* We fell into a pragma. Skip it, and continue. */
- cp_parser_skip_to_pragma_eol (parser, token);
+ cp_parser_skip_to_pragma_eol (parser, recovering ? token : nullptr);
continue;
default:
/* Consume tokens until we reach the end of the pragma. The PRAGMA_TOK
parameter is the PRAGMA token, allowing us to purge the entire pragma
- sequence. */
+ sequence. PRAGMA_TOK can be NULL, if we're speculatively scanning
+ forwards (not error recovery). */
static void
cp_parser_skip_to_pragma_eol (cp_parser* parser, cp_token *pragma_tok)
{
cp_token *token;
- parser->lexer->in_pragma = false;
-
do
{
/* The preprocessor makes sure that a PRAGMA_EOL token appears
}
while (token->type != CPP_PRAGMA_EOL);
- /* Ensure that the pragma is not parsed again. */
- cp_lexer_purge_tokens_after (parser->lexer, pragma_tok);
+ if (pragma_tok)
+ {
+ /* Ensure that the pragma is not parsed again. */
+ cp_lexer_purge_tokens_after (parser->lexer, pragma_tok);
+ parser->lexer->in_pragma = false;
+ }
}
/* Require pragma end of line, resyncing with it as necessary. The
--- /dev/null
+// PR96257 we scan forwards checking for a compound literal. Do not
+// eat the tokens when doing that!
+/* { dg-require-effective-target fopenmp } */
+/* { dg-additional-options -fopenmp } */
+
+int
+f2 ()
+{
+ int s = (int // { dg-error "expected" }
+#pragma omp atomic capture
+ ){1};
+
+ int t = (int // { dg-error "expected" }
+#pragma omp atomic capture ){
+ {1};
+
+ return s + t;
+} // { dg-bogus "expected" }