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