]> granicus.if.org Git - clang/commitdiff
Fix OpenMP recovery with trailing tokens following the pragma
authorAlp Toker <alp@nuanti.com>
Wed, 18 Dec 2013 19:10:54 +0000 (19:10 +0000)
committerAlp Toker <alp@nuanti.com>
Wed, 18 Dec 2013 19:10:54 +0000 (19:10 +0000)
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
test/OpenMP/parallel_messages.cpp
test/OpenMP/threadprivate_messages.cpp

index 79a02eea42330d3ed2891cf0930e85997c5aa0e5..5224c6bdc192f12ffb2852488213872107c1804e 100644 (file)
@@ -298,6 +298,8 @@ bool Parser::SkipUntil(ArrayRef<tok::TokenKind> 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:
index d991ccfc3806705b725c226c5082cb323349855e..d20fefd7e37fa413f559659854988827b15f53d2 100644 (file)
@@ -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();
index 4858549a7038677a22b856de4e8cbec27b80e46a..1665c48cafbca0779bf091efd7960898a821c2fd 100644 (file)
@@ -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}}