From: Alexey Bataev Date: Mon, 19 Oct 2015 06:40:17 +0000 (+0000) Subject: [OPENMP] Fix for http://llvm.org/PR25221: Infinite loop while parsing OpenMP directive X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3e2fcf40ecc2ea6527fa7fd299e0be7fec9fa2db;p=clang [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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250684 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index 5b0704658a..26dc3998ad 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -282,6 +282,7 @@ bool Parser::SkipUntil(ArrayRef 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 index 0000000000..c9b5eb0b9c --- /dev/null +++ b/test/OpenMP/openmp_check.cpp @@ -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 ('}')}}