1 // RUN: %clang_cc1 -verify -fopenmp %s
2
foo()3 void foo() {
4 }
5
foobool(int argc)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}}
tmain(T argc,S ** argv)13 T tmain(T argc, S **argv) { //expected-note 2 {{declared here}}
14 #pragma omp distribute collapse // expected-error {{expected '(' after 'collapse'}}
15 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
16 #pragma omp distribute collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
17 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
18 #pragma omp distribute collapse () // expected-error {{expected expression}}
19 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
20 // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
21 // expected-error@+2 2 {{expression is not an integral constant expression}}
22 // expected-note@+1 2 {{read of non-const variable 'argc' is not allowed in a constant expression}}
23 #pragma omp distribute collapse (argc
24 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
25 // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
26 #pragma omp distribute collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
27 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
28 #pragma omp distribute collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp distribute' are ignored}}
29 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
30 #pragma omp distribute collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}}
31 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp distribute', but found only 1}}
32 // expected-error@+3 2 {{directive '#pragma omp distribute' cannot contain more than one 'collapse' clause}}
33 // expected-error@+2 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
34 // expected-error@+1 2 {{expression is not an integral constant expression}}
35 #pragma omp distribute collapse (foobool(argc)), collapse (true), collapse (-5)
36 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
37 #pragma omp distribute collapse (S) // expected-error {{'S' does not refer to a value}}
38 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
39 // expected-error@+1 2 {{expression is not an integral constant expression}}
40 #pragma omp distribute collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
41 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
42 #pragma omp distribute collapse (1)
43 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
44 #pragma omp distribute collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}}
45 for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
46 #pragma omp distribute collapse (2) // expected-note {{as specified in 'collapse' clause}}
47 foo(); // expected-error {{expected 2 for loops after '#pragma omp distribute'}}
48 return argc;
49 }
50
main(int argc,char ** argv)51 int main(int argc, char **argv) {
52 #pragma omp distribute collapse // expected-error {{expected '(' after 'collapse'}}
53 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
54 #pragma omp distribute collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
55 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
56 #pragma omp distribute collapse () // expected-error {{expected expression}}
57 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
58 #pragma omp distribute collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
59 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp distribute', but found only 1}}
60 #pragma omp distribute collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp distribute' are ignored}} expected-note {{as specified in 'collapse' clause}}
61 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp distribute', but found only 1}}
62 #pragma omp distribute collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}}
63 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
64 // expected-error@+3 {{expression is not an integral constant expression}}
65 // expected-error@+2 2 {{directive '#pragma omp distribute' cannot contain more than one 'collapse' clause}}
66 // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
67 #pragma omp distribute collapse (foobool(argc)), collapse (true), collapse (-5)
68 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
69 #pragma omp distribute collapse (S1) // expected-error {{'S1' does not refer to a value}}
70 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
71 // expected-error@+1 {{expression is not an integral constant expression}}
72 #pragma omp distribute collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
73 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
74 // expected-error@+3 {{statement after '#pragma omp distribute' must be a for loop}}
75 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
76 #pragma omp distribute collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
77 foo();
78 #pragma omp distribute collapse (2) // expected-note {{as specified in 'collapse' clause}}
79 foo(); // expected-error {{expected 2 for loops after '#pragma omp distribute'}}
80 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
81 return tmain<int, char, 1, 0>(argc, argv);
82 }
83
84