1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
2 // RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s -Wuninitialized
5 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
6 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++98 %s -Wuninitialized
7 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
9 // expected-note@* 0+{{declared here}}
14 bool foobool(int argc
) {
20 template <class T
, typename S
, int N
, int ST
>
21 T
tmain(T argc
, S
**argv
) {
22 #pragma omp target simd simdlen // expected-error {{expected '(' after 'simdlen'}}
23 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
25 #pragma omp target simd simdlen ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
26 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
28 #pragma omp target simd simdlen () // expected-error {{expected expression}}
29 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
31 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
32 // expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
33 #pragma omp target simd simdlen (argc
34 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
36 // expected-error@+1 {{argument to 'simdlen' clause must be a strictly positive integer value}}
37 #pragma omp target simd simdlen (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
38 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
40 #pragma omp target simd simdlen (1)) // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}}
41 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
43 #pragma omp target simd simdlen ((ST > 0) ? 1 + ST : 2)
44 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
46 // expected-error@+3 2 {{directive '#pragma omp target simd' cannot contain more than one 'simdlen' clause}}
47 // expected-error@+2 {{argument to 'simdlen' clause must be a strictly positive integer value}}
48 // expected-error@+1 2 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
49 #pragma omp target simd simdlen (foobool(argc)), simdlen (true), simdlen (-5)
50 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
52 #pragma omp target simd simdlen (S) // expected-error {{'S' does not refer to a value}}
53 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
55 #if __cplusplus <= 199711L
56 // expected-error@+4 2 {{integral constant expression}} expected-note@+4 0+{{constant expression}}
58 // expected-error@+2 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
60 #pragma omp target simd simdlen (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
61 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
63 #pragma omp target simd simdlen (4)
64 for (int i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
66 #pragma omp target simd simdlen (N) // expected-error {{argument to 'simdlen' clause must be a strictly positive integer value}}
67 for (T i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
69 #pragma omp target simd simdlen (2), safelen (4) // OK
70 for (T i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
72 #pragma omp target simd simdlen (4), safelen (4) // OK
73 for (T i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
75 #pragma omp target simd simdlen (8), safelen (4) // expected-error{{the value of 'simdlen' parameter must be less than or equal to the value of the 'safelen' parameter}}
76 for (T i
= ST
; i
< N
; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-ST
];
81 int main(int argc
, char **argv
) {
82 #pragma omp target simd simdlen // expected-error {{expected '(' after 'simdlen'}}
83 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
85 #pragma omp target simd simdlen ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
86 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
88 #pragma omp target simd simdlen () // expected-error {{expected expression}}
89 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
91 #pragma omp target simd simdlen (4 // expected-error {{expected ')'}} expected-note {{to match this '('}}
92 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
94 #pragma omp target simd simdlen (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}}
95 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
97 // expected-error@+1 {{integral constant expression}} expected-note@+1 0+{{constant expression}}
98 #pragma omp target simd simdlen (foobool(1) > 0 ? 1 : 2)
99 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
101 // expected-error@+3 {{integral constant expression}} expected-note@+3 0+{{constant expression}}
102 // expected-error@+2 2 {{directive '#pragma omp target simd' cannot contain more than one 'simdlen' clause}}
103 // expected-error@+1 {{argument to 'simdlen' clause must be a strictly positive integer value}}
104 #pragma omp target simd simdlen (foobool(argc)), simdlen (true), simdlen (-5)
105 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
107 #pragma omp target simd simdlen (S1) // expected-error {{'S1' does not refer to a value}}
108 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
110 #if __cplusplus <= 199711L
111 // expected-error@+4 {{integral constant expression}} expected-note@+4 0+{{constant expression}}
113 // expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
115 #pragma omp target simd simdlen (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
116 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
118 // expected-error@+3 {{statement after '#pragma omp target simd' must be a for loop}}
119 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
120 #pragma omp target simd simdlen(simdlen(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
123 #pragma omp target simd simdlen (2), safelen (4) // OK
124 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
126 #pragma omp target simd simdlen (4), safelen (4) // OK
127 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
129 #pragma omp target simd simdlen (8), safelen (4) // expected-error{{the value of 'simdlen' parameter must be less than or equal to the value of the 'safelen' parameter}}
130 for (int i
= 4; i
< 12; i
++) argv
[0][i
] = argv
[0][i
] - argv
[0][i
-4];
132 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 12, 4>' requested here}}
133 return tmain
<int, char, 12, 4>(argc
, argv
);