Alexey Bataev | 60e51c4 | 2019-10-10 20:13:02 +0000 | [diff] [blame] | 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 |
| 4 | |
| 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 |
| 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 | #pragma omp master taskloop 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 master taskloop 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 master taskloop 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 master taskloop 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 master taskloop 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 master taskloop collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp master taskloop' are ignored}} |
| 38 | for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; |
| 39 | #pragma omp master taskloop 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 master taskloop', but found only 1}} |
| 41 | // expected-error@+6 2 {{directive '#pragma omp master taskloop' cannot contain more than one 'collapse' clause}} |
| 42 | // expected-error@+5 {{argument to 'collapse' clause must be a strictly positive integer value}} |
| 43 | // expected-error@+4 2 {{expression is not an integral constant expression}} |
| 44 | #if __cplusplus >= 201103L |
| 45 | // expected-note@+2 2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} |
| 46 | #endif |
| 47 | #pragma omp master taskloop 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 master taskloop 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]; |
| 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 |
| 56 | #pragma omp master taskloop 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 master taskloop collapse (1) |
| 59 | for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; |
| 60 | #pragma omp master taskloop 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 master taskloop collapse (2) // expected-note {{as specified in 'collapse' clause}} |
| 63 | foo(); // expected-error {{expected 2 for loops after '#pragma omp master taskloop'}} |
| 64 | return argc; |
| 65 | } |
| 66 | |
| 67 | int main(int argc, char **argv) { |
| 68 | #pragma omp master taskloop 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 master taskloop 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 master taskloop 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 master taskloop 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 master taskloop', but found only 1}} |
| 76 | #pragma omp master taskloop collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp master taskloop' 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 master taskloop', but found only 1}} |
| 78 | // expected-error@+4 {{expression is not an integral constant expression}} |
| 79 | #if __cplusplus >= 201103L |
| 80 | // expected-note@+2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} |
| 81 | #endif |
| 82 | #pragma omp master taskloop collapse (foobool(1) > 0 ? 1 : 2) |
| 83 | for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; |
| 84 | // expected-error@+6 {{expression is not an integral constant expression}} |
| 85 | #if __cplusplus >= 201103L |
| 86 | // expected-note@+4 {{non-constexpr function 'foobool' cannot be used in a constant expression}} |
| 87 | #endif |
| 88 | // expected-error@+2 2 {{directive '#pragma omp master taskloop' cannot contain more than one 'collapse' clause}} |
| 89 | // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}} |
| 90 | #pragma omp master taskloop collapse (foobool(argc)), collapse (true), collapse (-5) |
| 91 | for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; |
| 92 | #pragma omp master taskloop collapse (S1) // expected-error {{'S1' does not refer to a value}} |
| 93 | for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; |
| 94 | #if __cplusplus <= 199711L |
| 95 | // expected-error@+4 {{expression is not an integral constant expression}} |
| 96 | #else |
| 97 | // expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}} |
| 98 | #endif |
| 99 | #pragma omp master taskloop collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 100 | for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; |
| 101 | // expected-error@+3 {{statement after '#pragma omp master taskloop' must be a for loop}} |
| 102 | // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}} |
| 103 | #pragma omp master taskloop collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} |
| 104 | foo(); |
| 105 | #pragma omp master taskloop collapse (2) // expected-note {{as specified in 'collapse' clause}} |
| 106 | foo(); // expected-error {{expected 2 for loops after '#pragma omp master taskloop'}} |
| 107 | // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}} |
| 108 | return tmain<int, char, 1, 0>(argc, argv); |
| 109 | } |
| 110 | |