Clang Project

clang_source_code/test/OpenMP/target_teams_distribute_simd_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 target teams distribute simd // expected-error {{unexpected OpenMP directive '#pragma omp target teams distribute simd'}}
12
13int main(int argc, char **argv) {
14#pragma omp target teams distribute simd { // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute simd' are ignored}}
15  for (int i = 0; i < argc; ++i)
16    foo();
17#pragma omp target teams distribute simd ( // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute simd' are ignored}}
18  for (int i = 0; i < argc; ++i)
19    foo();
20#pragma omp target teams distribute simd[ // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute simd' are ignored}}
21  for (int i = 0; i < argc; ++i)
22    foo();
23#pragma omp target teams distribute simd] // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute simd' are ignored}}
24  for (int i = 0; i < argc; ++i)
25    foo();
26#pragma omp target teams distribute simd) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute simd' are ignored}}
27  for (int i = 0; i < argc; ++i)
28    foo();
29#pragma omp target teams distribute simd } // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute simd' are ignored}}
30  for (int i = 0; i < argc; ++i)
31    foo();
32#pragma omp target teams distribute simd
33  for (int i = 0; i < argc; ++i)
34    foo();
35// expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute simd' are ignored}}
36#pragma omp target teams distribute simd unknown()
37  for (int i = 0; i < argc; ++i)
38    foo();
39L1:
40  for (int i = 0; i < argc; ++i)
41    foo();
42#pragma omp target teams distribute simd
43  for (int i = 0; i < argc; ++i)
44    foo();
45#pragma omp target teams distribute simd
46  for (int i = 0; i < argc; ++i) {
47    goto L1; // expected-error {{use of undeclared label 'L1'}}
48    argc++;
49  }
50
51  for (int i = 0; i < 10; ++i) {
52    switch (argc) {
53    case (0):
54#pragma omp target teams distribute simd
55      for (int i = 0; i < argc; ++i) {
56        foo();
57        break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
58        continue;
59      }
60    default:
61      break;
62    }
63  }
64// expected-error@+1 {{unexpected OpenMP clause 'default' in directive '#pragma omp target teams distribute simd'}}
65#pragma omp target teams distribute simd default(none)
66  for (int i = 0; i < 10; ++i)
67    ++argc;
68
69  goto L2; // expected-error {{use of undeclared label 'L2'}}
70#pragma omp target teams distribute simd
71  for (int i = 0; i < argc; ++i)
72  L2:
73  foo();
74#pragma omp target teams distribute simd
75  for (int i = 0; i < argc; ++i) {
76    return 1; // expected-error {{cannot return from OpenMP region}}
77  }
78
79  [[]] // expected-error {{an attribute list cannot appear here}}
80#pragma omp target teams distribute simd
81      for (int n = 0; n < 100; ++n) {
82  }
83
84#pragma omp target teams distribute simd copyin(pvt) // expected-error {{unexpected OpenMP clause 'copyin' in directive '#pragma omp target teams distribute simd'}}
85  for (int n = 0; n < 100; ++n) {}
86
87  return 0;
88}
89
90void test_ordered() {
91#pragma omp target teams distribute simd ordered // expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp target teams distribute simd'}}
92  for (int i = 0; i < 16; ++i)
93    ;
94}
95
96