parallel_for_messages.cpp revision ef8225444452a1486bd721f3285301fe84643b00
1// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 -std=c++11 -o - %s
2
3void foo() {
4}
5
6#pragma omp parallel for // expected-error {{unexpected OpenMP directive '#pragma omp parallel for'}}
7
8int main(int argc, char **argv) {
9  #pragma omp parallel for { // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
10  for(int i = 0; i < argc; ++i) foo();
11  #pragma omp parallel for ( // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
12  for(int i = 0; i < argc; ++i) foo();
13  #pragma omp parallel for [ // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
14  for(int i = 0; i < argc; ++i) foo();
15  #pragma omp parallel for ] // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
16  for(int i = 0; i < argc; ++i) foo();
17  #pragma omp parallel for ) // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
18  for(int i = 0; i < argc; ++i) foo();
19  #pragma omp parallel for } // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
20  for(int i = 0; i < argc; ++i) foo();
21  #pragma omp parallel for
22  for(int i = 0; i < argc; ++i) foo();
23  // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
24  #pragma omp parallel for unknown()
25  for(int i = 0; i < argc; ++i) foo();
26  L1:
27    for(int i = 0; i < argc; ++i) foo();
28  #pragma omp parallel for
29  for(int i = 0; i < argc; ++i) foo();
30  #pragma omp parallel for
31    for(int i = 0; i < argc; ++i)
32  {
33    goto L1; // expected-error {{use of undeclared label 'L1'}}
34    argc++;
35  }
36
37  for (int i = 0; i < 10; ++i) {
38    switch(argc) {
39     case (0):
40      #pragma omp parallel for
41      for(int i = 0; i < argc; ++i)
42      {
43        foo();
44        break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
45        continue;
46      }
47      default:
48       break;
49    }
50  }
51  #pragma omp parallel for default(none)
52  for (int i = 0; i < 10; ++i)
53  ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
54
55  goto L2; // expected-error {{use of undeclared label 'L2'}}
56  #pragma omp parallel for
57  for(int i = 0; i < argc; ++i) L2:foo();
58  #pragma omp parallel for
59  for(int i = 0; i < argc; ++i)
60  {
61    return 1; // expected-error {{cannot return from OpenMP region}}
62  }
63
64  [[]] // expected-error {{an attribute list cannot appear here}}
65  #pragma omp parallel for
66  for (int n = 0; n < 100; ++n) {}
67
68  return 0;
69}
70
71