]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/OpenMP/target_teams_distribute_collapse_messages.cpp
Vendor import of clang trunk r290819:
[FreeBSD/FreeBSD.git] / test / OpenMP / target_teams_distribute_collapse_messages.cpp
1 // RUN: %clang_cc1 -verify -fopenmp %s
2
3 void foo() {
4 }
5
6 bool foobool(int argc) {
7   return argc;
8 }
9
10 struct S1; // expected-note {{declared here}}
11
12 template <class T, typename S, int N, int ST> // expected-note {{declared here}}
13 T tmain(T argc, S **argv) { //expected-note 2 {{declared here}}
14 #pragma omp target teams distribute collapse // expected-error {{expected '(' after 'collapse'}}
15   for (int i = ST; i < N; i++)
16     argv[0][i] = argv[0][i] - argv[0][i-ST];
17
18 #pragma omp target teams distribute collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
19   for (int i = ST; i < N; i++)
20
21     argv[0][i] = argv[0][i] - argv[0][i-ST];
22 #pragma omp target teams distribute collapse () // expected-error {{expected expression}}
23   for (int i = ST; i < N; i++)
24     argv[0][i] = argv[0][i] - argv[0][i-ST];
25
26 // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
27 // expected-error@+2 2 {{expression is not an integral constant expression}}
28 // expected-note@+1 2 {{read of non-const variable 'argc' is not allowed in a constant expression}}
29 #pragma omp target teams distribute collapse (argc 
30   for (int i = ST; i < N; i++)
31     argv[0][i] = argv[0][i] - argv[0][i-ST];
32
33 // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
34 #pragma omp target teams distribute collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
35   for (int i = ST; i < N; i++)
36     argv[0][i] = argv[0][i] - argv[0][i-ST];
37
38 #pragma omp target teams distribute collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}}
39   for (int i = ST; i < N; i++)
40     argv[0][i] = argv[0][i] - argv[0][i-ST];
41
42 #pragma omp target teams distribute collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}}
43   for (int i = ST; i < N; i++)
44     argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp target teams distribute', but found only 1}}
45
46 // expected-error@+3 2 {{directive '#pragma omp target teams distribute' cannot contain more than one 'collapse' clause}}
47 // expected-error@+2 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
48 // expected-error@+1 2 {{expression is not an integral constant expression}}
49 #pragma omp target teams distribute collapse (foobool(argc)), collapse (true), collapse (-5)
50   for (int i = ST; i < N; i++)
51     argv[0][i] = argv[0][i] - argv[0][i-ST];
52
53 #pragma omp target teams distribute collapse (S) // expected-error {{'S' does not refer to a value}}
54   for (int i = ST; i < N; i++)
55     argv[0][i] = argv[0][i] - argv[0][i-ST];
56
57 // expected-error@+1 2 {{expression is not an integral constant expression}}
58 #pragma omp target teams distribute collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
59   for (int i = ST; i < N; i++)
60     argv[0][i] = argv[0][i] - argv[0][i-ST];
61
62 #pragma omp target teams distribute collapse (1)
63   for (int i = ST; i < N; i++)
64     argv[0][i] = argv[0][i] - argv[0][i-ST];
65
66 #pragma omp target teams distribute collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}}
67   for (T i = ST; i < N; i++)
68     argv[0][i] = argv[0][i] - argv[0][i-ST];
69
70 #pragma omp target teams distribute collapse (2) // expected-note {{as specified in 'collapse' clause}}
71   foo(); // expected-error {{expected 2 for loops after '#pragma omp target teams distribute'}}
72   return argc;
73 }
74
75 int main(int argc, char **argv) {
76 #pragma omp target teams distribute collapse // expected-error {{expected '(' after 'collapse'}}
77   for (int i = 4; i < 12; i++)
78     argv[0][i] = argv[0][i] - argv[0][i-4];
79
80 #pragma omp target teams distribute collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
81   for (int i = 4; i < 12; i++)
82     argv[0][i] = argv[0][i] - argv[0][i-4];
83
84 #pragma omp target teams distribute collapse () // expected-error {{expected expression}}
85   for (int i = 4; i < 12; i++)
86     argv[0][i] = argv[0][i] - argv[0][i-4];
87
88 #pragma omp target teams distribute collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
89   for (int i = 4; i < 12; i++)
90     argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}}
91
92 #pragma omp target teams distribute collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}}  expected-note {{as specified in 'collapse' clause}}
93   for (int i = 4; i < 12; i++)
94     argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}}
95
96 #pragma omp target teams distribute collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}}
97   for (int i = 4; i < 12; i++)
98     argv[0][i] = argv[0][i] - argv[0][i-4];
99
100 // expected-error@+3 {{expression is not an integral constant expression}}
101 // expected-error@+2 2 {{directive '#pragma omp target teams distribute' cannot contain more than one 'collapse' clause}}
102 // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
103 #pragma omp target teams distribute collapse (foobool(argc)), collapse (true), collapse (-5) 
104   for (int i = 4; i < 12; i++)
105     argv[0][i] = argv[0][i] - argv[0][i-4];
106
107 #pragma omp target teams distribute collapse (S1) // expected-error {{'S1' does not refer to a value}}
108   for (int i = 4; i < 12; i++)
109     argv[0][i] = argv[0][i] - argv[0][i-4];
110
111 // expected-error@+1 {{expression is not an integral constant expression}}
112 #pragma omp target teams distribute collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
113   for (int i = 4; i < 12; i++)
114     argv[0][i] = argv[0][i] - argv[0][i-4];
115
116 // expected-error@+3 {{statement after '#pragma omp target teams distribute' must be a for loop}}
117 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
118 #pragma omp target teams distribute collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
119   foo();
120
121 #pragma omp target teams distribute collapse (2) // expected-note {{as specified in 'collapse' clause}}
122   foo(); // expected-error {{expected 2 for loops after '#pragma omp target teams distribute'}}
123
124 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
125   return tmain<int, char, 1, 0>(argc, argv);
126 }
127