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