re PR c++/88258 (Infinite loop emitting diagnostics in the C++ front-end)
authorJakub Jelinek <jakub@redhat.com>
Sun, 2 Dec 2018 12:38:20 +0000 (13:38 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sun, 2 Dec 2018 12:38:20 +0000 (13:38 +0100)
PR c++/88258
* parser.c (cp_parser_skip_to_closing_parenthesis_1,
cp_parser_skip_to_end_of_statement,
cp_parser_skip_to_end_of_block_or_statement,
cp_parser_skip_to_closing_brace,
cp_parser_skip_to_closing_square_bracket,
cp_parser_skip_balanced_tokens): Don't treat CPP_PRAGMA_EOL specially
if in_pragma is false.

* g++.dg/gomp/pr88258.C: New test.

From-SVN: r266720

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gomp/pr88258.C [new file with mode: 0644]

index 922388499030000f7e3dea89e6793c11ac51276f..02f08ab26418bd10afc5b3b6d09783f06231c2dc 100644 (file)
@@ -1,3 +1,14 @@
+2018-12-02  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/88258
+       * parser.c (cp_parser_skip_to_closing_parenthesis_1,
+       cp_parser_skip_to_end_of_statement,
+       cp_parser_skip_to_end_of_block_or_statement,
+       cp_parser_skip_to_closing_brace,
+       cp_parser_skip_to_closing_square_bracket,
+       cp_parser_skip_balanced_tokens): Don't treat CPP_PRAGMA_EOL specially
+       if in_pragma is false.
+
 2018-12-01  Marek Polacek  <polacek@redhat.com>
 
        Implement P0634R3, Down with typename!
index e271e87a707991f062531a6ff464ca9efa2f1c66..ab6d2378622bee9060375fdebc591f6377a57b48 100644 (file)
@@ -3558,8 +3558,11 @@ cp_parser_skip_to_closing_parenthesis_1 (cp_parser *parser,
 
       switch (token->type)
        {
-       case CPP_EOF:
        case CPP_PRAGMA_EOL:
+         if (!parser->lexer->in_pragma)
+           break;
+         /* FALLTHRU */
+       case CPP_EOF:
          /* If we've run out of tokens, then there is no closing `)'.  */
          return 0;
 
@@ -3654,8 +3657,11 @@ cp_parser_skip_to_end_of_statement (cp_parser* parser)
 
       switch (token->type)
        {
-       case CPP_EOF:
        case CPP_PRAGMA_EOL:
+         if (!parser->lexer->in_pragma)
+           break;
+         /* FALLTHRU */
+       case CPP_EOF:
          /* If we've run out of tokens, stop.  */
          return;
 
@@ -3744,8 +3750,11 @@ cp_parser_skip_to_end_of_block_or_statement (cp_parser* parser)
 
       switch (token->type)
        {
-       case CPP_EOF:
        case CPP_PRAGMA_EOL:
+         if (!parser->lexer->in_pragma)
+           break;
+         /* FALLTHRU */
+       case CPP_EOF:
          /* If we've run out of tokens, stop.  */
          return;
 
@@ -3794,8 +3803,11 @@ cp_parser_skip_to_closing_brace (cp_parser *parser)
 
       switch (token->type)
        {
-       case CPP_EOF:
        case CPP_PRAGMA_EOL:
+         if (!parser->lexer->in_pragma)
+           break;
+         /* FALLTHRU */
+       case CPP_EOF:
          /* If we've run out of tokens, stop.  */
          return false;
 
@@ -22560,8 +22572,11 @@ cp_parser_skip_to_closing_square_bracket (cp_parser *parser)
 
       switch (token->type)
        {
-       case CPP_EOF:
        case CPP_PRAGMA_EOL:
+         if (!parser->lexer->in_pragma)
+           break;
+         /* FALLTHRU */
+       case CPP_EOF:
          /* If we've run out of tokens, then there is no closing `]'.  */
          return false;
 
@@ -26074,8 +26089,11 @@ cp_parser_skip_balanced_tokens (cp_parser *parser, size_t n)
   do
     switch (cp_lexer_peek_nth_token (parser->lexer, n++)->type)
       {
-      case CPP_EOF:
       case CPP_PRAGMA_EOL:
+       if (!parser->lexer->in_pragma)
+         break;
+       /* FALLTHRU */
+      case CPP_EOF:
        /* Ran out of tokens.  */
        return orig_n;
       case CPP_OPEN_PAREN:
index 2cdbba498b722685c5f6e1225a6491d481728edd..92825b59b21108ab3297afa9d2af39c23d548460 100644 (file)
@@ -1,3 +1,8 @@
+2018-12-02  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/88258
+       * g++.dg/gomp/pr88258.C: New test.
+
 2018-12-01  Marek Polacek  <polacek@redhat.com>
 
        Implement P0634R3, Down with typename!
diff --git a/gcc/testsuite/g++.dg/gomp/pr88258.C b/gcc/testsuite/g++.dg/gomp/pr88258.C
new file mode 100644 (file)
index 0000000..9981bdb
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/88258
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+void
+foo (bar int p)                // { dg-error "variable or field|was not declared in this scope" }
+{
+  int i, x;
+  #pragma omp atomic write
+  x = 6;
+}