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