blob: 79128706bc94aac2ce13c43ab974d4d5a67acca4 [file] [log] [blame]
Kelvin Li4e325f72016-10-25 12:50:55 +00001// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s
2
Alexey Bataeva8a9153a2017-12-29 18:07:07 +00003// RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s
4
Kelvin Li4e325f72016-10-25 12:50:55 +00005void foo() {
6}
7
8static int pvt;
9#pragma omp threadprivate(pvt)
10
11#pragma omp teams distribute simd // expected-error {{unexpected OpenMP directive '#pragma omp teams distribute simd'}}
12
13int main(int argc, char **argv) {
Alexey Bataevceabd412017-11-30 18:01:54 +000014 #pragma omp target
15 #pragma omp teams distribute simd
16 f; // expected-error {{use of undeclared identifier 'f'}}
Kelvin Li4e325f72016-10-25 12:50:55 +000017#pragma omp target
18#pragma omp teams distribute simd { // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}
19 for (int i = 0; i < argc; ++i)
20 foo();
21#pragma omp target
22#pragma omp teams distribute simd ( // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}
23 for (int i = 0; i < argc; ++i)
24 foo();
25#pragma omp target
26#pragma omp teams distribute simd[ // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}
27 for (int i = 0; i < argc; ++i)
28 foo();
29#pragma omp target
30#pragma omp teams distribute simd] // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}
31 for (int i = 0; i < argc; ++i)
32 foo();
33#pragma omp target
34#pragma omp teams distribute simd) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}
35 for (int i = 0; i < argc; ++i)
36 foo();
37#pragma omp target
38#pragma omp teams distribute simd } // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}
39 for (int i = 0; i < argc; ++i)
40 foo();
41#pragma omp target
42#pragma omp teams distribute simd
43 for (int i = 0; i < argc; ++i)
44 foo();
45// expected-warning@+2 {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}
46#pragma omp target
47#pragma omp teams distribute simd 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 simd
55 for (int i = 0; i < argc; ++i)
56 foo();
57#pragma omp target
58#pragma omp teams distribute simd
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 simd
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 simd 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 simd
86 for (int i = 0; i < argc; ++i)
87 L2:
88 foo();
89#pragma omp target
90#pragma omp teams distribute simd
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 simd
98 for (int n = 0; n < 100; ++n) {
99 }
100
101#pragma omp target
102#pragma omp teams distribute simd copyin(pvt) // expected-error {{unexpected OpenMP clause 'copyin' in directive '#pragma omp teams distribute simd'}}
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 simd ordered // expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp teams distribute simd'}}
111 for (int i = 0; i < 16; ++i)
112 ;
113}
114