Clang Project

clang_source_code/test/OpenMP/teams_distribute_parallel_for_messages.cpp
1// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s
2
3// RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s
4
5void foo() {
6}
7
8static int pvt;
9#pragma omp threadprivate(pvt)
10
11#pragma omp teams distribute parallel for // expected-error {{unexpected OpenMP directive '#pragma omp teams distribute parallel for'}}
12
13int main(int argc, char **argv) {
14  #pragma omp target
15  #pragma omp teams distribute parallel for
16  f; // expected-error {{use of undeclared identifier 'f'}}
17#pragma omp target
18#pragma omp teams distribute parallel for { // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
19  for (int i = 0; i < argc; ++i)
20    foo();
21#pragma omp target
22#pragma omp teams distribute parallel for ( // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
23  for (int i = 0; i < argc; ++i)
24    foo();
25#pragma omp target
26#pragma omp teams distribute parallel for[ // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
27  for (int i = 0; i < argc; ++i)
28    foo();
29#pragma omp target
30#pragma omp teams distribute parallel for] // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
31  for (int i = 0; i < argc; ++i)
32    foo();
33#pragma omp target
34#pragma omp teams distribute parallel for) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
35  for (int i = 0; i < argc; ++i)
36    foo();
37#pragma omp target
38#pragma omp teams distribute parallel for } // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
39  for (int i = 0; i < argc; ++i)
40    foo();
41#pragma omp target
42#pragma omp teams distribute parallel for linear(argc) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp teams distribute parallel for'}}
43  for (int i = 0; i < argc; ++i)
44    foo();
45// expected-warning@+2 {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
46#pragma omp target
47#pragma omp teams distribute parallel for unknown()
48  for (int i = 0; i < argc; ++i)
49    foo();
50L1:
51  for (int i = 0; i < argc; ++i)
52    foo();
53#pragma omp target
54#pragma omp teams distribute parallel for
55  for (int i = 0; i < argc; ++i)
56    foo();
57#pragma omp target
58#pragma omp teams distribute parallel for
59  for (int i = 0; i < argc; ++i) {
60    goto L1; // expected-error {{use of undeclared label 'L1'}}
61    argc++;
62  }
63
64  for (int i = 0; i < 10; ++i) {
65    switch (argc) {
66    case (0):
67#pragma omp target
68#pragma omp teams distribute parallel for
69      for (int i = 0; i < argc; ++i) {
70        foo();
71        break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
72        continue;
73      }
74    default:
75      break;
76    }
77  }
78#pragma omp target
79#pragma omp teams distribute parallel for default(none)
80  for (int i = 0; i < 10; ++i)
81    ++argc; // expected-error {{ariable 'argc' must have explicitly specified data sharing attributes}}
82
83  goto L2; // expected-error {{use of undeclared label 'L2'}}
84#pragma omp target
85#pragma omp teams distribute parallel for
86  for (int i = 0; i < argc; ++i)
87  L2:
88  foo();
89#pragma omp target
90#pragma omp teams distribute parallel for
91  for (int i = 0; i < argc; ++i) {
92    return 1; // expected-error {{cannot return from OpenMP region}}
93  }
94
95  [[]] // expected-error {{an attribute list cannot appear here}}
96#pragma omp target
97#pragma omp teams distribute parallel for
98      for (int n = 0; n < 100; ++n) {
99  }
100
101#pragma omp target
102#pragma omp teams distribute parallel for copyin(pvt)
103  for (int n = 0; n < 100; ++n) {}
104
105  return 0;
106}
107
108void test_ordered() {
109#pragma omp target
110#pragma omp teams distribute parallel for ordered // expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp teams distribute parallel for'}}
111  for (int i = 0; i < 16; ++i)
112    ;
113}
114
115void test_cancel() {
116#pragma omp target
117#pragma omp teams distribute parallel for
118  for (int i = 0; i < 16; ++i) {
119#pragma omp cancel for
120    ;
121  }
122}
123
124