From 7742deb9e03e5129dbe6148f5c9a55af73bd8535 Mon Sep 17 00:00:00 2001 From: Alp Toker Date: Wed, 18 Dec 2013 19:10:54 +0000 Subject: [PATCH] Fix OpenMP recovery with trailing tokens following the pragma The recovery was failing due to a missing case in SkipUntil(). Also add back tests from r197553 that were reverted in the previous commit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197598 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Parse/Parser.cpp | 2 ++ test/OpenMP/parallel_messages.cpp | 12 ++++++++++++ test/OpenMP/threadprivate_messages.cpp | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index 79a02eea42..5224c6bdc1 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -298,6 +298,8 @@ bool Parser::SkipUntil(ArrayRef Toks, SkipUntilFlags Flags) { // Ran out of tokens. return false; + case tok::annot_pragma_openmp_end: + // Stop before an OpenMP pragma boundary. case tok::annot_module_begin: case tok::annot_module_end: case tok::annot_module_include: diff --git a/test/OpenMP/parallel_messages.cpp b/test/OpenMP/parallel_messages.cpp index d991ccfc38..d20fefd7e3 100644 --- a/test/OpenMP/parallel_messages.cpp +++ b/test/OpenMP/parallel_messages.cpp @@ -6,6 +6,18 @@ void foo() { #pragma omp parallel // expected-error {{unexpected OpenMP directive '#pragma omp parallel'}} int main(int argc, char **argv) { + #pragma omp parallel { // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}} + foo(); + #pragma omp parallel ( // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}} + foo(); + #pragma omp parallel [ // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}} + foo(); + #pragma omp parallel ] // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}} + foo(); + #pragma omp parallel ) // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}} + foo(); + #pragma omp parallel } // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}} + foo(); #pragma omp parallel #pragma omp parallel unknown() // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}} foo(); diff --git a/test/OpenMP/threadprivate_messages.cpp b/test/OpenMP/threadprivate_messages.cpp index 4858549a70..1665c48caf 100644 --- a/test/OpenMP/threadprivate_messages.cpp +++ b/test/OpenMP/threadprivate_messages.cpp @@ -24,6 +24,12 @@ int foo() { // expected-note {{declared here}} return (a); } +#pragma omp threadprivate (a) ( // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'a'}} expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} +#pragma omp threadprivate (a) [ // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'a'}} expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} +#pragma omp threadprivate (a) { // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'a'}} expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} +#pragma omp threadprivate (a) ) // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'a'}} expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} +#pragma omp threadprivate (a) ] // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'a'}} expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} +#pragma omp threadprivate (a) } // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'a'}} expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} #pragma omp threadprivate a // expected-error {{expected '(' after 'threadprivate'}} #pragma omp threadprivate(d // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{'#pragma omp threadprivate' must precede all references to variable 'd'}} #pragma omp threadprivate(d)) // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'd'}} expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} -- 2.40.0