xref: /llvm-project/clang/test/OpenMP/for_order_messages.cpp (revision 0c6f2f629cc0017361310fa4c132090413a874db)
1 // RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=50 -triple x86_64-unknown-unknown -verify=expected,omp50 %s -Wuninitialized
2 // RUN: %clang_cc1 -fsyntax-only -fopenmp -triple x86_64-unknown-unknown -verify=expected,omp51 %s -Wuninitialized
3 
4 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=50 -triple x86_64-unknown-unknown -verify=expected,omp50 %s -Wuninitialized
5 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -triple x86_64-unknown-unknown -verify=expected,omp51 %s -Wuninitialized
6 
7 extern int omp_get_num_threads  (void);
8 
main(int argc,char ** argv)9 int main(int argc, char **argv) {
10   int A = 0;
11 #pragma omp parallel for order(concurrent)
12   for (int i = 0; i < 10; ++i)
13     omp_get_num_threads(); // omp51-error {{calls to OpenMP runtime API are not allowed within a region that corresponds to a construct with an order clause that specifies concurrent}}
14 
15 #pragma omp parallel for order(reproducible:concurrent) // omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
16   for (int i = 0; i < 10; ++i)
17     omp_get_num_threads(); // omp51-error {{calls to OpenMP runtime API are not allowed within a region that corresponds to a construct with an order clause that specifies concurrent}}
18 
19 #pragma omp parallel for order(unconstrained:concurrent) // omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
20   for (int i = 0; i < 10; ++i)
21     omp_get_num_threads(); // omp51-error {{calls to OpenMP runtime API are not allowed within a region that corresponds to a construct with an order clause that specifies concurrent}}
22 
23 #pragma omp parallel for order(concurrent)
24   for (int i = 0; i < 10; ++i) {
25     for (int j = 0; j < 10; ++j) {
26       omp_get_num_threads(); // omp51-error {{calls to OpenMP runtime API are not allowed within a region that corresponds to a construct with an order clause that specifies concurrent}}
27     }
28   }
29 
30 #pragma omp parallel for order(concurrent)
31   for (int i = 0; i < 10; ++i) {
32 #pragma omp atomic //omp51-error {{construct 'atomic' not allowed in a region associated with a directive with 'order' clause}}
33       A++;
34   }
35 
36 #pragma omp parallel for order(reproducible: concurrent) // omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
37   for (int i = 0; i < 10; ++i) {
38 #pragma omp target //omp51-error {{construct 'target' not allowed in a region associated with a directive with 'order' clause}}
39       A++;
40   }
41 
42 #pragma omp parallel for order(unconstrained: concurrent) // omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
43   for (int i = 0; i < 10; ++i) {
44 #pragma omp target //omp51-error {{construct 'target' not allowed in a region associated with a directive with 'order' clause}}
45       A++;
46   }
47 }
48