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 parallel for simd safelen // expected-error {{expected '(' after 'safelen'}}
15 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
16 #pragma omp parallel for simd safelen ( // 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 parallel for simd safelen () // 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 parallel for simd safelen (argc
24 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
25 // expected-error@+1 {{argument to 'safelen' clause must be a strictly positive integer value}}
26 #pragma omp parallel for simd safelen (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 parallel for simd safelen (1)) // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
29 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
30 #pragma omp parallel for simd safelen ((ST > 0) ? 1 + ST : 2)
31 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
32 // expected-error@+3 2 {{directive '#pragma omp parallel for simd' cannot contain more than one 'safelen' clause}}
33 // expected-error@+2 2 {{argument to 'safelen' clause must be a strictly positive integer value}}
34 // expected-error@+1 2 {{expression is not an integral constant expression}}
35 #pragma omp parallel for simd safelen (foobool(argc)), safelen (true), safelen (-5)
36 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
37 #pragma omp parallel for simd safelen (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 parallel for simd safelen (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 parallel for simd safelen (4)
43 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
44 #pragma omp parallel for simd safelen (N) // expected-error {{argument to 'safelen' 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 return argc;
47 }
48
main(int argc,char ** argv)49 int main(int argc, char **argv) {
50 #pragma omp parallel for simd safelen // expected-error {{expected '(' after 'safelen'}}
51 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
52 #pragma omp parallel for simd safelen ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
53 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
54 #pragma omp parallel for simd safelen () // expected-error {{expected expression}}
55 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
56 #pragma omp parallel for simd safelen (4 // expected-error {{expected ')'}} expected-note {{to match this '('}}
57 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
58 #pragma omp parallel for simd safelen (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
59 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
60 #pragma omp parallel for simd safelen (foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}}
61 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
62 // expected-error@+3 {{expression is not an integral constant expression}}
63 // expected-error@+2 2 {{directive '#pragma omp parallel for simd' cannot contain more than one 'safelen' clause}}
64 // expected-error@+1 2 {{argument to 'safelen' clause must be a strictly positive integer value}}
65 #pragma omp parallel for simd safelen (foobool(argc)), safelen (true), safelen (-5)
66 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
67 #pragma omp parallel for simd safelen (S1) // expected-error {{'S1' does not refer to a value}}
68 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
69 // expected-error@+1 {{expression is not an integral constant expression}}
70 #pragma omp parallel for simd safelen (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
71 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
72 // expected-error@+3 {{statement after '#pragma omp parallel for simd' must be a for loop}}
73 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
74 #pragma omp parallel for simd safelen(safelen(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
75 foo();
76 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 12, 4>' requested here}}
77 return tmain<int, char, 12, 4>(argc, argv);
78 }
79
80