114a388f4SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
214a388f4SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s -Wuninitialized
314a388f4SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s -Wuninitialized
414a388f4SAlexey Bataev 
514a388f4SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
614a388f4SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++98 %s -Wuninitialized
714a388f4SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
814a388f4SAlexey Bataev 
9*ebf6fd63SRichard Smith // expected-note@* 0+{{declared here}}
10*ebf6fd63SRichard Smith 
foo()1114a388f4SAlexey Bataev void foo() {
1214a388f4SAlexey Bataev }
1314a388f4SAlexey Bataev 
foobool(int argc)1414a388f4SAlexey Bataev bool foobool(int argc) {
1514a388f4SAlexey Bataev   return argc;
1614a388f4SAlexey Bataev }
1714a388f4SAlexey Bataev 
18*ebf6fd63SRichard Smith struct S1;
1914a388f4SAlexey Bataev 
20*ebf6fd63SRichard Smith template <class T, typename S, int N, int ST>
tmain(T argc,S ** argv)21*ebf6fd63SRichard Smith T tmain(T argc, S **argv) {
2214a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd simdlen // expected-error {{expected '(' after 'simdlen'}}
2314a388f4SAlexey Bataev   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
2414a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd simdlen ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
2514a388f4SAlexey Bataev   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
2614a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd simdlen () // expected-error {{expected expression}}
2714a388f4SAlexey Bataev   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
28*ebf6fd63SRichard Smith   // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
29*ebf6fd63SRichard Smith   // expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
3014a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd simdlen (argc
3114a388f4SAlexey Bataev   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
3214a388f4SAlexey Bataev   // expected-error@+1 {{argument to 'simdlen' clause must be a strictly positive integer value}}
3314a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd simdlen (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
3414a388f4SAlexey Bataev   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
3514a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd simdlen (1)) // expected-warning {{extra tokens at the end of '#pragma omp parallel master taskloop simd' are ignored}}
3614a388f4SAlexey Bataev   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
3714a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd simdlen ((ST > 0) ? 1 + ST : 2)
3814a388f4SAlexey Bataev   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
39*ebf6fd63SRichard Smith   // expected-error@+3 2 {{directive '#pragma omp parallel master taskloop simd' cannot contain more than one 'simdlen' clause}}
40*ebf6fd63SRichard Smith   // expected-error@+2 {{argument to 'simdlen' clause must be a strictly positive integer value}}
41*ebf6fd63SRichard Smith   // expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
4214a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd simdlen (foobool(argc)), simdlen (true), simdlen (-5)
4314a388f4SAlexey Bataev   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
4414a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd simdlen (S) // expected-error {{'S' does not refer to a value}}
4514a388f4SAlexey Bataev   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
4614a388f4SAlexey Bataev #if __cplusplus <= 199711L
47*ebf6fd63SRichard Smith   // expected-error@+4 2 {{integral constant expression}} expected-note@+4 0+{{constant expression}}
4814a388f4SAlexey Bataev #else
4914a388f4SAlexey Bataev   // expected-error@+2 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
5014a388f4SAlexey Bataev #endif
5114a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd simdlen (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
5214a388f4SAlexey Bataev   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
5314a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd simdlen (4)
5414a388f4SAlexey Bataev   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
5514a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd simdlen (N) // expected-error {{argument to 'simdlen' clause must be a strictly positive integer value}}
5614a388f4SAlexey Bataev   for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
5714a388f4SAlexey Bataev   return argc;
5814a388f4SAlexey Bataev }
5914a388f4SAlexey Bataev 
main(int argc,char ** argv)6014a388f4SAlexey Bataev int main(int argc, char **argv) {
6114a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd simdlen // expected-error {{expected '(' after 'simdlen'}}
6214a388f4SAlexey Bataev   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
6314a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd simdlen ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
6414a388f4SAlexey Bataev   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
6514a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd simdlen () // expected-error {{expected expression}}
6614a388f4SAlexey Bataev   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
6714a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd simdlen (4 // expected-error {{expected ')'}} expected-note {{to match this '('}}
6814a388f4SAlexey Bataev   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
6914a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd simdlen (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp parallel master taskloop simd' are ignored}}
7014a388f4SAlexey Bataev   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
71*ebf6fd63SRichard Smith   // expected-error@+1 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
7214a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd simdlen (foobool(1) > 0 ? 1 : 2)
7314a388f4SAlexey Bataev   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
74*ebf6fd63SRichard Smith   // expected-error@+3 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
7514a388f4SAlexey Bataev   // expected-error@+2 2 {{directive '#pragma omp parallel master taskloop simd' cannot contain more than one 'simdlen' clause}}
7614a388f4SAlexey Bataev   // expected-error@+1 {{argument to 'simdlen' clause must be a strictly positive integer value}}
7714a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd simdlen (foobool(argc)), simdlen (true), simdlen (-5)
7814a388f4SAlexey Bataev   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
7914a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd simdlen (S1) // expected-error {{'S1' does not refer to a value}}
8014a388f4SAlexey Bataev   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
8114a388f4SAlexey Bataev #if __cplusplus <= 199711L
82*ebf6fd63SRichard Smith   // expected-error@+4 {{integral constant expression}} expected-note@+4 0+{{constant expression}}
8314a388f4SAlexey Bataev #else
8414a388f4SAlexey Bataev   // expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
8514a388f4SAlexey Bataev #endif
8614a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd simdlen (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
8714a388f4SAlexey Bataev   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
8814a388f4SAlexey Bataev   // expected-error@+3 {{statement after '#pragma omp parallel master taskloop simd' must be a for loop}}
8914a388f4SAlexey Bataev   // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
9014a388f4SAlexey Bataev   #pragma omp parallel master taskloop simd simdlen(simdlen(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
9114a388f4SAlexey Bataev   foo();
9214a388f4SAlexey Bataev   // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 12, 4>' requested here}}
9314a388f4SAlexey Bataev   return tmain<int, char, 12, 4>(argc, argv);
9414a388f4SAlexey Bataev }
9514a388f4SAlexey Bataev 
96