]> granicus.if.org Git - clang/commitdiff
[OPENMP] Fix for http://llvm.org/PR25221: Infinite loop while parsing OpenMP directive
authorAlexey Bataev <a.bataev@hotmail.com>
Mon, 19 Oct 2015 06:40:17 +0000 (06:40 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Mon, 19 Oct 2015 06:40:17 +0000 (06:40 +0000)
Clang skipped annot_pragma_openmp token, while it should be considered as a stop token while skipping tokens.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250684 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/Parser.cpp
test/OpenMP/openmp_check.cpp [new file with mode: 0644]

index 5b0704658a251cee624bcd78348686444b649562..26dc3998ad80df245f615cb2f39aa9a5e507e687 100644 (file)
@@ -282,6 +282,7 @@ bool Parser::SkipUntil(ArrayRef<tok::TokenKind> Toks, SkipUntilFlags Flags) {
       // Ran out of tokens.
       return false;
 
+    case tok::annot_pragma_openmp:
     case tok::annot_pragma_openmp_end:
       // Stop before an OpenMP pragma boundary.
     case tok::annot_module_begin:
diff --git a/test/OpenMP/openmp_check.cpp b/test/OpenMP/openmp_check.cpp
new file mode 100644 (file)
index 0000000..c9b5eb0
--- /dev/null
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
+int nested(int a) {
+#pragma omp parallel
+  ++a;
+
+  auto F = [&]() { // expected-error {{expected expression}} expected-error {{expected ';' at end of declaration}} expected-warning {{'auto' type specifier is a C++11 extension}}
+#pragma omp parallel
+    {
+#pragma omp target
+      ++a;
+    }
+  };
+  F(); // expected-error {{C++ requires a type specifier for all declarations}}
+  return a; // expected-error {{expected unqualified-id}}
+}// expected-error {{extraneous closing brace ('}')}}