Kelvin Li | 986330c | 2016-07-20 22:57:10 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify -fopenmp %s |
| 2 | // RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s |
| 3 | |
Alexey Bataev | a8a9153a | 2017-12-29 18:07:07 +0000 | [diff] [blame^] | 4 | // RUN: %clang_cc1 -verify -fopenmp-simd %s |
| 5 | // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s |
| 6 | |
Kelvin Li | 986330c | 2016-07-20 22:57:10 +0000 | [diff] [blame] | 7 | void foo() { |
| 8 | } |
| 9 | |
| 10 | #if __cplusplus >= 201103L |
| 11 | // expected-note@+2 4 {{declared here}} |
| 12 | #endif |
| 13 | bool foobool(int argc) { |
| 14 | return argc; |
| 15 | } |
| 16 | |
| 17 | struct S1; // expected-note {{declared here}} |
| 18 | |
| 19 | template <class T, typename S, int N, int ST> // expected-note {{declared here}} |
| 20 | T tmain(T argc, S **argv) { //expected-note 2 {{declared here}} |
| 21 | int j; // expected-note {{declared here}} |
| 22 | #pragma omp target simd collapse // expected-error {{expected '(' after 'collapse'}} |
| 23 | for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; |
| 24 | #pragma omp target simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 25 | for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; |
| 26 | #pragma omp target simd collapse () // expected-error {{expected expression}} |
| 27 | for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; |
| 28 | // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}} |
| 29 | // expected-error@+2 2 {{expression is not an integral constant expression}} |
| 30 | // expected-note@+1 2 {{read of non-const variable 'argc' is not allowed in a constant expression}} |
| 31 | #pragma omp target simd collapse (argc |
| 32 | for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; |
| 33 | // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}} |
| 34 | #pragma omp target simd collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 35 | for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; |
| 36 | #pragma omp target simd collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} |
| 37 | for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; |
| 38 | #pragma omp target simd collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}} |
| 39 | for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp target simd', but found only 1}} |
| 40 | #if __cplusplus >= 201103L |
| 41 | // expected-note@+5 2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} |
| 42 | #endif |
| 43 | // expected-error@+3 2 {{directive '#pragma omp target simd' cannot contain more than one 'collapse' clause}} |
| 44 | // expected-error@+2 2 {{argument to 'collapse' clause must be a strictly positive integer value}} |
| 45 | // expected-error@+1 2 {{expression is not an integral constant expression}} |
| 46 | #pragma omp target simd collapse (foobool(argc)), collapse (true), collapse (-5) |
| 47 | for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; |
| 48 | #pragma omp target simd collapse (S) // expected-error {{'S' does not refer to a value}} |
| 49 | for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; |
| 50 | // expected-note@+2 {{read of non-const variable 'j' is not allowed in a constant expression}} |
| 51 | // expected-error@+1 {{expression is not an integral constant expression}} |
| 52 | #pragma omp target simd collapse (j=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 53 | for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; |
| 54 | #pragma omp target simd collapse (1) |
| 55 | for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; |
| 56 | #pragma omp target simd collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}} |
| 57 | for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; |
| 58 | #pragma omp target simd collapse (2) // expected-note {{as specified in 'collapse' clause}} |
| 59 | foo(); // expected-error {{expected 2 for loops after '#pragma omp target simd'}} |
| 60 | return argc; |
| 61 | } |
| 62 | |
| 63 | int main(int argc, char **argv) { |
| 64 | int j; // expected-note {{declared here}} |
| 65 | #pragma omp target simd collapse // expected-error {{expected '(' after 'collapse'}} |
| 66 | for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; |
| 67 | #pragma omp target simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 68 | for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; |
| 69 | #pragma omp target simd collapse () // expected-error {{expected expression}} |
| 70 | for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; |
| 71 | #pragma omp target simd collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}} |
| 72 | for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp target simd', but found only 1}} |
| 73 | #pragma omp target simd collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp target simd' are ignored}} expected-note {{as specified in 'collapse' clause}} |
| 74 | for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp target simd', but found only 1}} |
| 75 | #if __cplusplus >= 201103L |
| 76 | // expected-note@+2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} |
| 77 | #endif |
| 78 | #pragma omp target simd collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}} |
| 79 | for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; |
| 80 | #if __cplusplus >= 201103L |
| 81 | // expected-note@+5 {{non-constexpr function 'foobool' cannot be used in a constant expression}} |
| 82 | #endif |
| 83 | // expected-error@+3 {{expression is not an integral constant expression}} |
| 84 | // expected-error@+2 2 {{directive '#pragma omp target simd' cannot contain more than one 'collapse' clause}} |
| 85 | // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}} |
| 86 | #pragma omp target simd collapse (foobool(argc)), collapse (true), collapse (-5) |
| 87 | for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; |
| 88 | #pragma omp target simd collapse (S1) // expected-error {{'S1' does not refer to a value}} |
| 89 | for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; |
| 90 | // expected-note@+2 {{read of non-const variable 'j' is not allowed in a constant expression}} |
| 91 | // expected-error@+1 {{expression is not an integral constant expression}} |
| 92 | #pragma omp target simd collapse (j=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 93 | for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; |
| 94 | // expected-error@+3 {{statement after '#pragma omp target simd' must be a for loop}} |
| 95 | // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}} |
| 96 | #pragma omp target simd collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} |
| 97 | foo(); |
| 98 | #pragma omp target simd collapse (2) // expected-note {{as specified in 'collapse' clause}} |
| 99 | foo(); // expected-error {{expected 2 for loops after '#pragma omp target simd'}} |
| 100 | // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}} |
| 101 | return tmain<int, char, 1, 0>(argc, argv); |
| 102 | } |
| 103 | |