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