149764dc3SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -ferror-limit 150 %s
2fcba7c35SAlexey Bataev 
349764dc3SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -ferror-limit 150 %s
4fcba7c35SAlexey Bataev 
5fcba7c35SAlexey Bataev template <class T>
tmain()649764dc3SAlexey Bataev T tmain() {
749764dc3SAlexey Bataev   static T argc;
8fcba7c35SAlexey Bataev #pragma omp for
9fcba7c35SAlexey Bataev   for (int i = 0; i < 10; ++i) {
1006dea733SAlexey Bataev #pragma omp scan // expected-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}}
11fcba7c35SAlexey Bataev     ;
12fcba7c35SAlexey Bataev   }
13fcba7c35SAlexey Bataev #pragma omp for
14fcba7c35SAlexey Bataev   for (int i = 0; i < 10; ++i) {
1506dea733SAlexey Bataev #pragma omp scan allocate(argc)  // expected-error {{unexpected OpenMP clause 'allocate' in directive '#pragma omp scan'}} expected-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}}
1606dea733SAlexey Bataev #pragma omp scan untied  // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp scan'}} expected-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}}
1706dea733SAlexey Bataev #pragma omp scan unknown // expected-warning {{extra tokens at the end of '#pragma omp scan' are ignored}} expected-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}}
18fcba7c35SAlexey Bataev   }
1949764dc3SAlexey Bataev #pragma omp for simd reduction(inscan, +: argc)
20fcba7c35SAlexey Bataev   for (int i = 0; i < 10; ++i)
21fcba7c35SAlexey Bataev     if (argc)
22*bd1c03d7SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
23fcba7c35SAlexey Bataev     if (argc) {
242a43a161SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
25fcba7c35SAlexey Bataev     }
2649764dc3SAlexey Bataev #pragma omp simd reduction(inscan, +: argc)
27fcba7c35SAlexey Bataev   for (int i = 0; i < 10; ++i)
28fcba7c35SAlexey Bataev   while (argc)
29*bd1c03d7SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
30fcba7c35SAlexey Bataev     while (argc) {
312a43a161SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
32fcba7c35SAlexey Bataev     }
3349764dc3SAlexey Bataev #pragma omp simd reduction(inscan, +: argc)
34fcba7c35SAlexey Bataev   for (int i = 0; i < 10; ++i)
35fcba7c35SAlexey Bataev   do
36*bd1c03d7SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
37fcba7c35SAlexey Bataev     while (argc)
38fcba7c35SAlexey Bataev       ;
39*bd1c03d7SAlexey Bataev #pragma omp simd reduction(inscan, +: argc) // expected-error {{the inscan reduction list item must appear as a list item in an 'inclusive' or 'exclusive' clause on an inner 'omp scan' directive}}
40fcba7c35SAlexey Bataev   for (int i = 0; i < 10; ++i)
41fcba7c35SAlexey Bataev   do {
42*bd1c03d7SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
43fcba7c35SAlexey Bataev   } while (argc);
4449764dc3SAlexey Bataev #pragma omp simd reduction(inscan, +: argc)
45fcba7c35SAlexey Bataev   for (int i = 0; i < 10; ++i)
46fcba7c35SAlexey Bataev   switch (argc)
47*bd1c03d7SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
48fcba7c35SAlexey Bataev     switch (argc)
49fcba7c35SAlexey Bataev     case 1:
502a43a161SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
51fcba7c35SAlexey Bataev   switch (argc)
52fcba7c35SAlexey Bataev   case 1: {
532a43a161SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
54fcba7c35SAlexey Bataev   }
55*bd1c03d7SAlexey Bataev #pragma omp simd reduction(inscan, +: argc) // expected-error {{the inscan reduction list item must appear as a list item in an 'inclusive' or 'exclusive' clause on an inner 'omp scan' directive}}
56fcba7c35SAlexey Bataev   for (int i = 0; i < 10; ++i)
57fcba7c35SAlexey Bataev   switch (argc) {
58*bd1c03d7SAlexey Bataev #pragma omp scan exclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
59fcba7c35SAlexey Bataev   case 1:
60*bd1c03d7SAlexey Bataev #pragma omp scan exclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
61fcba7c35SAlexey Bataev     break;
62fcba7c35SAlexey Bataev   default: {
63*bd1c03d7SAlexey Bataev #pragma omp scan exclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
64fcba7c35SAlexey Bataev   } break;
65fcba7c35SAlexey Bataev   }
6649764dc3SAlexey Bataev #pragma omp simd reduction(inscan, +: argc)
67fcba7c35SAlexey Bataev   for (int i = 0; i < 10; ++i)
68fcba7c35SAlexey Bataev   for (;;)
69*bd1c03d7SAlexey Bataev #pragma omp scan exclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
70fcba7c35SAlexey Bataev     for (;;) {
712a43a161SAlexey Bataev #pragma omp scan exclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
72fcba7c35SAlexey Bataev     }
7349764dc3SAlexey Bataev #pragma omp simd reduction(inscan, +: argc)
74fcba7c35SAlexey Bataev   for (int i = 0; i < 10; ++i) {
75fcba7c35SAlexey Bataev label:
7663828a35SAlexey Bataev #pragma omp scan exclusive(argc)
77fcba7c35SAlexey Bataev   }
7849764dc3SAlexey Bataev #pragma omp simd reduction(inscan, +: argc)
79fcba7c35SAlexey Bataev   for (int i = 0; i < 10; ++i) {
80*bd1c03d7SAlexey Bataev #pragma omp scan inclusive(argc) // expected-note {{previous 'scan' directive used here}}
81*bd1c03d7SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{exactly one 'scan' directive must appear in the loop body of an enclosing directive}}
82fcba7c35SAlexey Bataev label1 : {
83*bd1c03d7SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
84fcba7c35SAlexey Bataev }}
85fcba7c35SAlexey Bataev 
86fcba7c35SAlexey Bataev   return T();
87fcba7c35SAlexey Bataev }
88fcba7c35SAlexey Bataev 
main()8949764dc3SAlexey Bataev int main() {
9049764dc3SAlexey Bataev   static int argc;
9149764dc3SAlexey Bataev #pragma omp simd reduction(inscan, +: argc)
92fcba7c35SAlexey Bataev   for (int i = 0; i < 10; ++i) {
9306dea733SAlexey Bataev #pragma omp scan inclusive(argc) inclusive(argc) // expected-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}}
94fcba7c35SAlexey Bataev   ;
95fcba7c35SAlexey Bataev   }
9649764dc3SAlexey Bataev #pragma omp simd reduction(inscan, +: argc)
97fcba7c35SAlexey Bataev   for (int i = 0; i < 10; ++i) {
9863828a35SAlexey Bataev #pragma omp scan exclusive(argc) inclusive(argc) // expected-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}}
9963828a35SAlexey Bataev   ;
10063828a35SAlexey Bataev   }
10149764dc3SAlexey Bataev #pragma omp simd reduction(inscan, +: argc)
10263828a35SAlexey Bataev   for (int i = 0; i < 10; ++i) {
10363828a35SAlexey Bataev #pragma omp scan exclusive(argc) exclusive(argc) // expected-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}}
10463828a35SAlexey Bataev   ;
10563828a35SAlexey Bataev   }
10649764dc3SAlexey Bataev #pragma omp simd reduction(inscan, +: argc) // expected-error {{the inscan reduction list item must appear as a list item in an 'inclusive' or 'exclusive' clause on an inner 'omp scan' directive}}
10763828a35SAlexey Bataev   for (int i = 0; i < 10; ++i) {
10806dea733SAlexey Bataev #pragma omp scan untied  // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp scan'}} expected-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}}
10906dea733SAlexey Bataev #pragma omp scan unknown // expected-warning {{extra tokens at the end of '#pragma omp scan' are ignored}} expected-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}}
110fcba7c35SAlexey Bataev   }
11149764dc3SAlexey Bataev #pragma omp simd reduction(inscan, +: argc)
112fcba7c35SAlexey Bataev   for (int i = 0; i < 10; ++i)
113fcba7c35SAlexey Bataev   if (argc)
114*bd1c03d7SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
115fcba7c35SAlexey Bataev     if (argc) {
11649764dc3SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}} expected-error {{the list item must appear in 'reduction' clause with the 'inscan' modifier of the parent directive}}
117fcba7c35SAlexey Bataev     }
11849764dc3SAlexey Bataev #pragma omp simd reduction(inscan, +: argc)
119fcba7c35SAlexey Bataev   for (int i = 0; i < 10; ++i)
120fcba7c35SAlexey Bataev   while (argc)
121*bd1c03d7SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
122fcba7c35SAlexey Bataev     while (argc) {
12349764dc3SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}} expected-error {{the list item must appear in 'reduction' clause with the 'inscan' modifier of the parent directive}}
124fcba7c35SAlexey Bataev     }
12549764dc3SAlexey Bataev #pragma omp simd reduction(inscan, +: argc)
126fcba7c35SAlexey Bataev   for (int i = 0; i < 10; ++i)
127fcba7c35SAlexey Bataev   do
128*bd1c03d7SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
129fcba7c35SAlexey Bataev     while (argc)
130fcba7c35SAlexey Bataev       ;
13149764dc3SAlexey Bataev #pragma omp simd reduction(inscan, +: argc)
132fcba7c35SAlexey Bataev   for (int i = 0; i < 10; ++i)
133fcba7c35SAlexey Bataev   do {
134*bd1c03d7SAlexey Bataev #pragma omp scan exclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
135fcba7c35SAlexey Bataev   } while (argc);
13649764dc3SAlexey Bataev #pragma omp simd reduction(inscan, +: argc)
137fcba7c35SAlexey Bataev   for (int i = 0; i < 10; ++i)
138fcba7c35SAlexey Bataev   switch (argc)
139*bd1c03d7SAlexey Bataev #pragma omp scan exclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
140fcba7c35SAlexey Bataev     switch (argc)
141fcba7c35SAlexey Bataev     case 1:
14249764dc3SAlexey Bataev #pragma omp scan exclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}} expected-error {{the list item must appear in 'reduction' clause with the 'inscan' modifier of the parent directive}}
143fcba7c35SAlexey Bataev   switch (argc)
144fcba7c35SAlexey Bataev   case 1: {
14549764dc3SAlexey Bataev #pragma omp scan exclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}} expected-error {{the list item must appear in 'reduction' clause with the 'inscan' modifier of the parent directive}}
146fcba7c35SAlexey Bataev   }
14749764dc3SAlexey Bataev #pragma omp simd reduction(inscan, +: argc)
148fcba7c35SAlexey Bataev   for (int i = 0; i < 10; ++i)
149fcba7c35SAlexey Bataev   switch (argc) {
150*bd1c03d7SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
151fcba7c35SAlexey Bataev   case 1:
152*bd1c03d7SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
153fcba7c35SAlexey Bataev     break;
154fcba7c35SAlexey Bataev   default: {
155*bd1c03d7SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
156fcba7c35SAlexey Bataev   } break;
157fcba7c35SAlexey Bataev   }
15849764dc3SAlexey Bataev #pragma omp simd reduction(inscan, +: argc)
159fcba7c35SAlexey Bataev   for (int i = 0; i < 10; ++i)
160fcba7c35SAlexey Bataev   for (;;)
161*bd1c03d7SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
162fcba7c35SAlexey Bataev     for (;;) {
16349764dc3SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}} expected-error {{the list item must appear in 'reduction' clause with the 'inscan' modifier of the parent directive}}
164fcba7c35SAlexey Bataev     }
16549764dc3SAlexey Bataev #pragma omp simd reduction(inscan, +: argc)
166fcba7c35SAlexey Bataev   for (int i = 0; i < 10; ++i) {
167fcba7c35SAlexey Bataev label:
16806dea733SAlexey Bataev #pragma omp scan inclusive(argc)
169fcba7c35SAlexey Bataev   }
17049764dc3SAlexey Bataev #pragma omp simd reduction(inscan, +: argc)
171fcba7c35SAlexey Bataev   for (int i = 0; i < 10; ++i) {
172*bd1c03d7SAlexey Bataev #pragma omp scan inclusive(argc) // expected-note {{previous 'scan' directive used here}}
173*bd1c03d7SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{exactly one 'scan' directive must appear in the loop body of an enclosing directive}}
174fcba7c35SAlexey Bataev label1 : {
175*bd1c03d7SAlexey Bataev #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
176fcba7c35SAlexey Bataev }
177fcba7c35SAlexey Bataev }
178fcba7c35SAlexey Bataev 
179*bd1c03d7SAlexey Bataev   return tmain<int>(); // expected-note {{in instantiation of function template specialization 'tmain<int>' requested here}}
180fcba7c35SAlexey Bataev }
181