| 1 |
// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized |
| 2 |
|
| 3 |
// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized |
| 4 |
|
| 5 |
void foo() { |
| 6 |
} |
| 7 |
|
| 8 |
bool foobool(int argc) { |
| 9 |
return argc; |
| 10 |
} |
| 11 |
|
| 12 |
struct S1; // expected-note {{declared here}} |
| 13 |
|
| 14 |
template <class T, typename S, int N> // expected-note {{declared here}} |
| 15 |
T tmain(T argc, S **argv) { |
| 16 |
T i, k; |
| 17 |
#pragma omp target |
| 18 |
#pragma omp teams distribute parallel for simd num_threads // expected-error {{expected '(' after 'num_threads'}} |
| 19 |
for (i = 0; i < argc; ++i) foo(); |
| 20 |
#pragma omp target |
| 21 |
#pragma omp teams distribute parallel for simd num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 22 |
for (i = 0; i < argc; ++i) foo(); |
| 23 |
#pragma omp target |
| 24 |
#pragma omp teams distribute parallel for simd num_threads () // expected-error {{expected expression}} |
| 25 |
for (i = 0; i < argc; ++i) foo(); |
| 26 |
#pragma omp target |
| 27 |
#pragma omp teams distribute parallel for simd num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 28 |
for (i = 0; i < argc; ++i) foo(); |
| 29 |
#pragma omp target |
| 30 |
#pragma omp teams distribute parallel for simd num_threads (k)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for simd' are ignored}} |
| 31 |
for (i = 0; i < argc; ++i) foo(); |
| 32 |
#pragma omp target |
| 33 |
#pragma omp teams distribute parallel for simd num_threads ((argc > 0) ? argv[1] : argv[2]) // expected-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}} |
| 34 |
for (i = 0; i < argc; ++i) foo(); |
| 35 |
#pragma omp target |
| 36 |
#pragma omp teams distribute parallel for simd num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp teams distribute parallel for simd' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}} |
| 37 |
for (i = 0; i < argc; ++i) foo(); |
| 38 |
#pragma omp target |
| 39 |
#pragma omp teams distribute parallel for simd num_threads (S) // expected-error {{'S' does not refer to a value}} |
| 40 |
for (i = 0; i < argc; ++i) foo(); |
| 41 |
#pragma omp target |
| 42 |
#pragma omp teams distribute parallel for simd num_threads (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}} |
| 43 |
for (i = 0; i < argc; ++i) foo(); |
| 44 |
#pragma omp target |
| 45 |
#pragma omp teams distribute parallel for simd num_threads (argc) |
| 46 |
for (i = 0; i < argc; ++i) foo(); |
| 47 |
#pragma omp target |
| 48 |
#pragma omp teams distribute parallel for simd num_threads (N) // expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}} |
| 49 |
for (i = 0; i < argc; ++i) foo(); |
| 50 |
|
| 51 |
return argc; |
| 52 |
} |
| 53 |
|
| 54 |
int main(int argc, char **argv) { |
| 55 |
int i, k; |
| 56 |
#pragma omp target |
| 57 |
#pragma omp teams distribute parallel for simd num_threads // expected-error {{expected '(' after 'num_threads'}} |
| 58 |
for (i = 0; i < argc; ++i) foo(); |
| 59 |
#pragma omp target |
| 60 |
#pragma omp teams distribute parallel for simd num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 61 |
for (i = 0; i < argc; ++i) foo(); |
| 62 |
#pragma omp target |
| 63 |
#pragma omp teams distribute parallel for simd num_threads () // expected-error {{expected expression}} |
| 64 |
for (i = 0; i < argc; ++i) foo(); |
| 65 |
#pragma omp target |
| 66 |
#pragma omp teams distribute parallel for simd num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 67 |
for (i = 0; i < argc; ++i) foo(); |
| 68 |
#pragma omp target |
| 69 |
#pragma omp teams distribute parallel for simd num_threads (k)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for simd' are ignored}} |
| 70 |
for (i = 0; i < argc; ++i) foo(); |
| 71 |
#pragma omp target |
| 72 |
#pragma omp teams distribute parallel for simd num_threads (argc > 0 ? argv[1] : argv[2]) // expected-error {{integral }} |
| 73 |
for (i = 0; i < argc; ++i) foo(); |
| 74 |
#pragma omp target |
| 75 |
#pragma omp teams distribute parallel for simd num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp teams distribute parallel for simd' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}} |
| 76 |
for (i = 0; i < argc; ++i) foo(); |
| 77 |
#pragma omp target |
| 78 |
#pragma omp teams distribute parallel for simd num_threads (S1) // expected-error {{'S1' does not refer to a value}} |
| 79 |
for (i = 0; i < argc; ++i) foo(); |
| 80 |
#pragma omp target |
| 81 |
#pragma omp teams distribute parallel for simd num_threads (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} |
| 82 |
for (i = 0; i < argc; ++i) foo(); |
| 83 |
#pragma omp target |
| 84 |
#pragma omp teams distribute parallel for simd num_threads (num_threads(tmain<int, char, -1>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} expected-note {{in instantiation of function template specialization 'tmain<int, char, -1>' requested here}} |
| 85 |
for (i = 0; i < argc; ++i) foo(); |
| 86 |
|
| 87 |
return tmain<int, char, 3>(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain<int, char, 3>' requested here}} |
| 88 |
} |