r250684 - [OPENMP] Fix for http://llvm.org/PR25221: Infinite loop while parsing OpenMP directive

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 18 23:40:18 PDT 2015


Author: abataev
Date: Mon Oct 19 01:40:17 2015
New Revision: 250684

URL: http://llvm.org/viewvc/llvm-project?rev=250684&view=rev
Log:
[OPENMP] Fix for http://llvm.org/PR25221: Infinite loop while parsing OpenMP directive
Clang skipped annot_pragma_openmp token, while it should be considered as a stop token while skipping tokens.

Added:
    cfe/trunk/test/OpenMP/openmp_check.cpp   (with props)
Modified:
    cfe/trunk/lib/Parse/Parser.cpp

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=250684&r1=250683&r2=250684&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Mon Oct 19 01:40:17 2015
@@ -282,6 +282,7 @@ bool Parser::SkipUntil(ArrayRef<tok::Tok
       // 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:

Added: cfe/trunk/test/OpenMP/openmp_check.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/openmp_check.cpp?rev=250684&view=auto
==============================================================================
--- cfe/trunk/test/OpenMP/openmp_check.cpp (added)
+++ cfe/trunk/test/OpenMP/openmp_check.cpp Mon Oct 19 01:40:17 2015
@@ -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 ('}')}}

Propchange: cfe/trunk/test/OpenMP/openmp_check.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cfe/trunk/test/OpenMP/openmp_check.cpp
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/OpenMP/openmp_check.cpp
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the cfe-commits mailing list