]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/41967 (gcc get into endless loop when compiling an openmp program)
authorJakub Jelinek <jakub@redhat.com>
Fri, 6 Nov 2009 17:51:20 +0000 (18:51 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 6 Nov 2009 17:51:20 +0000 (18:51 +0100)
PR c++/41967
* parser.c (cp_parser_omp_for_loop): After diagnosing not perfectly
nested loop and parsing statements, don't cp_parser_require }, instead
exit the loop if next token is CPP_EOF.

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

From-SVN: r153972

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

index e909ba22396af1aee6ec8e2ed6c38485c7abe961..21a2221538583cdb9a1426de4e6db13e4580b8f0 100644 (file)
@@ -1,3 +1,10 @@
+2009-11-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/41967
+       * parser.c (cp_parser_omp_for_loop): After diagnosing not perfectly
+       nested loop and parsing statements, don't cp_parser_require }, instead
+       exit the loop if next token is CPP_EOF.
+
 2009-11-05  Jason Merrill  <jason@redhat.com>
 
        PR c++/34180
index 28fcabc313d726ba69e2d30a752ed2e9f1a77434..1d677cb92ebe077cb0c05c576283e34d2e3a0e44 100644 (file)
@@ -22424,7 +22424,8 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
            }
          collapse_err = true;
          cp_parser_statement_seq_opt (parser, NULL);
-         cp_parser_require (parser, CPP_CLOSE_BRACE, "%<}%>");
+         if (cp_lexer_next_token_is (parser->lexer, CPP_EOF))
+           break;
        }
     }
 
index 60159c1d32afffb060040bd97061a069278d65fa..5ea0e42aa0432ddb6606acac5eb82d1248cffd5d 100644 (file)
@@ -1,3 +1,8 @@
+2009-11-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/41967
+       * g++.dg/gomp/pr41967.C: New test.
+
 2009-11-06  Michael Matz  <matz@suse.de>
 
        PR middle-end/41963
diff --git a/gcc/testsuite/g++.dg/gomp/pr41967.C b/gcc/testsuite/g++.dg/gomp/pr41967.C
new file mode 100644 (file)
index 0000000..0eb489e
--- /dev/null
@@ -0,0 +1,17 @@
+// PR c++/41967
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+int
+foo ()
+{
+  int sum = 0;
+#pragma omp for collapse(2)
+  for (int i = 0; i < 5; ++i)
+    {
+      for (int j = 0; j < 5; ++j)
+       ++sum;
+      ++sum;   // { dg-error "collapsed loops not perfectly nested" }
+    }
+  return sum;
+}
This page took 0.100859 seconds and 5 git commands to generate.