1 // RUN: %clang_cc1 -verify -fopenmp %s
2 // RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s
3 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s
4
foo()5 void foo() {
6 }
7
8 #if __cplusplus >= 201103L
9 // expected-note@+2 4 {{declared here}}
10 #endif
foobool(int argc)11 bool foobool(int argc) {
12 return argc;
13 }
14
15 struct S1; // expected-note {{declared here}}
16
17 template <class T, typename S, int N, int ST> // expected-note {{declared here}}
tmain(T argc,S ** argv)18 T tmain(T argc, S **argv) { //expected-note 2 {{declared here}}
19
20 #pragma omp target
21 #pragma omp teams
22 #pragma omp distribute parallel for simd safelen // expected-error {{expected '(' after 'safelen'}}
23 for (int i = ST; i < N; i++)
24 argv[0][i] = argv[0][i] - argv[0][i-ST];
25
26 #pragma omp target
27 #pragma omp teams
28 #pragma omp distribute parallel for simd safelen ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
29 for (int i = ST; i < N; i++)
30 argv[0][i] = argv[0][i] - argv[0][i-ST];
31
32 #pragma omp target
33 #pragma omp teams
34 #pragma omp distribute parallel for simd safelen () // expected-error {{expected expression}}
35 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
36
37 #pragma omp target
38 #pragma omp teams
39 #pragma omp distribute parallel for simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{expression is not an integral constant expression}} expected-note 2 {{read of non-const variable 'argc' is not allowed in a constant expression}} expected-error {{expected ')'}}
40 for (int i = ST; i < N; i++)
41 argv[0][i] = argv[0][i] - argv[0][i-ST];
42
43 #pragma omp target
44 #pragma omp teams
45 #pragma omp distribute parallel for simd safelen (ST // expected-error {{argument to 'safelen' clause must be a strictly positive integer value}} expected-error {{expected ')'}} expected-note {{to match this '('}}
46 for (int i = ST; i < N; i++)
47 argv[0][i] = argv[0][i] - argv[0][i-ST];
48
49 #pragma omp target
50 #pragma omp teams
51 #pragma omp distribute parallel for simd safelen (1)) // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for simd' are ignored}}
52 for (int i = ST; i < N; i++)
53 argv[0][i] = argv[0][i] - argv[0][i-ST];
54
55 #pragma omp target
56 #pragma omp teams
57 #pragma omp distribute parallel for simd safelen ((ST > 0) ? 1 + ST : 2)
58 for (int i = ST; i < N; i++)
59 argv[0][i] = argv[0][i] - argv[0][i-ST];
60
61 #if __cplusplus >= 201103L
62 // expected-note@+4 2 {{non-constexpr function 'foobool' cannot be used in a constant expression}}
63 #endif
64 #pragma omp target
65 #pragma omp teams
66 #pragma omp distribute parallel for simd safelen (foobool(argc)), safelen (true), safelen (-5) // expected-error 2 {{directive '#pragma omp distribute parallel for simd' cannot contain more than one 'safelen' clause}} expected-error 2 {{argument to 'safelen' clause must be a strictly positive integer value}} expected-error 2 {{expression is not an integral constant expression}}
67 for (int i = ST; i < N; i++)
68 argv[0][i] = argv[0][i] - argv[0][i-ST];
69
70 #pragma omp target
71 #pragma omp teams
72 #pragma omp distribute parallel for simd safelen (S) // expected-error {{'S' does not refer to a value}}
73 for (int i = ST; i < N; i++)
74 argv[0][i] = argv[0][i] - argv[0][i-ST];
75
76 #if __cplusplus <= 199711L
77 // expected-error@+6 2 {{expression is not an integral constant expression}}
78 #else
79 // expected-error@+4 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
80 #endif
81 #pragma omp target
82 #pragma omp teams
83 #pragma omp distribute parallel for simd safelen (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
84 for (int i = ST; i < N; i++)
85 argv[0][i] = argv[0][i] - argv[0][i-ST];
86
87 #pragma omp target
88 #pragma omp teams
89 #pragma omp distribute parallel for simd safelen (4)
90 for (int i = ST; i < N; i++)
91 argv[0][i] = argv[0][i] - argv[0][i-ST];
92
93 #pragma omp target
94 #pragma omp teams
95 #pragma omp distribute parallel for simd safelen (N) // expected-error {{argument to 'safelen' clause must be a strictly positive integer value}}
96 for (T i = ST; i < N; i++)
97 argv[0][i] = argv[0][i] - argv[0][i-ST];
98
99 return argc;
100 }
101
main(int argc,char ** argv)102 int main(int argc, char **argv) {
103 #pragma omp target
104 #pragma omp teams
105 #pragma omp parallel for simd safelen // expected-error {{expected '(' after 'safelen'}}
106 for (int i = 4; i < 12; i++)
107 argv[0][i] = argv[0][i] - argv[0][i-4];
108
109 #pragma omp target
110 #pragma omp teams
111 #pragma omp parallel for simd safelen ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
112 for (int i = 4; i < 12; i++)
113 argv[0][i] = argv[0][i] - argv[0][i-4];
114
115 #pragma omp target
116 #pragma omp teams
117 #pragma omp parallel for simd safelen () // expected-error {{expected expression}}
118 for (int i = 4; i < 12; i++)
119 argv[0][i] = argv[0][i] - argv[0][i-4];
120
121 #pragma omp target
122 #pragma omp teams
123 #pragma omp parallel for simd safelen (4 // expected-error {{expected ')'}} expected-note {{to match this '('}}
124 for (int i = 4; i < 12; i++)
125 argv[0][i] = argv[0][i] - argv[0][i-4];
126
127 #pragma omp target
128 #pragma omp teams
129 #pragma omp parallel for simd safelen (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
130 for (int i = 4; i < 12; i++)
131 argv[0][i] = argv[0][i] - argv[0][i-4];
132
133 #if __cplusplus >= 201103L
134 // expected-note@+4 {{non-constexpr function 'foobool' cannot be used in a constant expression}}
135 #endif
136 #pragma omp target
137 #pragma omp teams
138 #pragma omp parallel for simd safelen (foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}}
139 for (int i = 4; i < 12; i++)
140 argv[0][i] = argv[0][i] - argv[0][i-4];
141
142 #if __cplusplus >= 201103L
143 // expected-note@+4 {{non-constexpr function 'foobool' cannot be used in a constant expression}}
144 #endif
145 #pragma omp target
146 #pragma omp teams
147 #pragma omp parallel for simd safelen (foobool(argc)), safelen (true), safelen (-5) // expected-error 2 {{argument to 'safelen' clause must be a strictly positive integer value}} expected-error 2 {{directive '#pragma omp parallel for simd' cannot contain more than one 'safelen' clause}} expected-error {{expression is not an integral constant expression}}
148 for (int i = 4; i < 12; i++)
149 argv[0][i] = argv[0][i] - argv[0][i-4];
150
151 #pragma omp target
152 #pragma omp teams
153 #pragma omp parallel for simd safelen (S1) // expected-error {{'S1' does not refer to a value}}
154 for (int i = 4; i < 12; i++)
155 argv[0][i] = argv[0][i] - argv[0][i-4];
156
157 #if __cplusplus <= 199711L
158 // expected-error@+6 {{expression is not an integral constant expression}}
159 #else
160 // expected-error@+4 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
161 #endif
162 #pragma omp target
163 #pragma omp teams
164 #pragma omp distribute parallel for simd safelen (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
165 for (int i = 4; i < 12; i++)
166 argv[0][i] = argv[0][i] - argv[0][i-4];
167
168 // expected-note@+3 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
169 #pragma omp target
170 #pragma omp teams
171 #pragma omp distribute parallel for simd safelen(safelen(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
172 foo(); // expected-error {{statement after '#pragma omp distribute parallel for simd' must be a for loop}}
173
174 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 12, 4>' requested here}}
175 return tmain<int, char, 12, 4>(argc, argv);
176 }
177
178