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 target
     20 #pragma omp teams
     21 #pragma omp distribute parallel for simd simdlen // expected-error {{expected '(' after 'simdlen'}}
     22   for (int i = ST; i < N; i++)
     23     argv[0][i] = argv[0][i] - argv[0][i-ST];
     24 
     25 #pragma omp target
     26 #pragma omp teams
     27 #pragma omp distribute parallel for simd simdlen ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     28   for (int i = ST; i < N; i++)
     29     argv[0][i] = argv[0][i] - argv[0][i-ST];
     30 
     31 #pragma omp target
     32 #pragma omp teams
     33 #pragma omp distribute parallel for simd simdlen () // expected-error {{expected expression}}
     34   for (int i = ST; i < N; i++)
     35     argv[0][i] = argv[0][i] - argv[0][i-ST];
     36 
     37 // expected-error@+5 {{expected ')'}} expected-note@+5 {{to match this '('}}
     38 // expected-error@+4 2 {{expression is not an integral constant expression}}
     39 // expected-note@+3 2 {{read of non-const variable 'argc' is not allowed in a constant expression}}
     40 #pragma omp target
     41 #pragma omp teams
     42 #pragma omp distribute parallel for simd simdlen (argc
     43   for (int i = ST; i < N; i++)
     44     argv[0][i] = argv[0][i] - argv[0][i-ST];
     45 
     46 // expected-error@+3 {{argument to 'simdlen' clause must be a strictly positive integer value}}
     47 #pragma omp target
     48 #pragma omp teams
     49 #pragma omp distribute parallel for simd simdlen (ST // 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 
     53 #pragma omp target
     54 #pragma omp teams
     55 #pragma omp distribute parallel for simd simdlen (1)) // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for simd' are ignored}}
     56   for (int i = ST; i < N; i++)
     57     argv[0][i] = argv[0][i] - argv[0][i-ST];
     58 
     59 #pragma omp target
     60 #pragma omp teams
     61 #pragma omp distribute parallel for simd simdlen ((ST > 0) ? 1 + ST : 2)
     62   for (int i = ST; i < N; i++)
     63     argv[0][i] = argv[0][i] - argv[0][i-ST];
     64 
     65 #if __cplusplus >= 201103L
     66   // expected-note@+4 2 {{non-constexpr function 'foobool' cannot be used in a constant expression}}
     67 #endif
     68 #pragma omp target
     69 #pragma omp teams
     70 #pragma omp distribute parallel for simd simdlen (foobool(argc)), simdlen (true), simdlen (-5) // expected-error 2 {{directive '#pragma omp distribute parallel for simd' cannot contain more than one 'simdlen' clause}} expected-error 2 {{argument to 'simdlen' clause must be a strictly positive integer value}} expected-error 2 {{expression is not an integral constant expression}}
     71   for (int i = ST; i < N; i++)
     72     argv[0][i] = argv[0][i] - argv[0][i-ST];
     73 
     74 #pragma omp target
     75 #pragma omp teams
     76 #pragma omp distribute parallel for simd simdlen (S) // expected-error {{'S' does not refer to a value}}
     77   for (int i = ST; i < N; i++)
     78     argv[0][i] = argv[0][i] - argv[0][i-ST];
     79 
     80 #if __cplusplus <= 199711L
     81   // expected-error@+6 2 {{expression is not an integral constant expression}}
     82 #else
     83   // expected-error@+4 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
     84 #endif
     85 #pragma omp target
     86 #pragma omp teams
     87 #pragma omp distribute parallel for simd simdlen (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
     88   for (int i = ST; i < N; i++)
     89     argv[0][i] = argv[0][i] - argv[0][i-ST];
     90 
     91 #pragma omp target
     92 #pragma omp teams
     93 #pragma omp distribute parallel for simd simdlen (4)
     94   for (int i = ST; i < N; i++)
     95     argv[0][i] = argv[0][i] - argv[0][i-ST];
     96 
     97 #pragma omp target
     98 #pragma omp teams
     99 #pragma omp distribute parallel for simd simdlen (N) // expected-error {{argument to 'simdlen' clause must be a strictly positive integer value}}
    100   for (T i = ST; i < N; i++)
    101     argv[0][i] = argv[0][i] - argv[0][i-ST];
    102 
    103   return argc;
    104 }
    105 
    106 int main(int argc, char **argv) {
    107 #pragma omp target
    108 #pragma omp teams
    109 #pragma omp distribute parallel for simd simdlen // expected-error {{expected '(' after 'simdlen'}}
    110   for (int i = 4; i < 12; i++)
    111     argv[0][i] = argv[0][i] - argv[0][i-4];
    112 
    113 #pragma omp target
    114 #pragma omp teams
    115 #pragma omp distribute parallel for simd simdlen ( // expected-error {{expected expression}} 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 
    119 #pragma omp target
    120 #pragma omp teams
    121 #pragma omp distribute parallel for simd simdlen () // expected-error {{expected expression}}
    122   for (int i = 4; i < 12; i++)
    123     argv[0][i] = argv[0][i] - argv[0][i-4];
    124 
    125 #pragma omp target
    126 #pragma omp teams
    127 #pragma omp distribute parallel for simd simdlen (4 // expected-error {{expected ')'}} expected-note {{to match this '('}}
    128   for (int i = 4; i < 12; i++)
    129     argv[0][i] = argv[0][i] - argv[0][i-4];
    130 
    131 #pragma omp target
    132 #pragma omp teams
    133 #pragma omp distribute parallel for simd simdlen (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for simd' are ignored}}
    134   for (int i = 4; i < 12; i++)
    135     argv[0][i] = argv[0][i] - argv[0][i-4];
    136 
    137 #if __cplusplus >= 201103L
    138   // expected-note@+4 {{non-constexpr function 'foobool' cannot be used in a constant expression}}
    139 #endif
    140 #pragma omp target
    141 #pragma omp teams
    142 #pragma omp distribute parallel for simd simdlen (foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}}
    143   for (int i = 4; i < 12; i++)
    144     argv[0][i] = argv[0][i] - argv[0][i-4];
    145 
    146 
    147 #if __cplusplus >= 201103L
    148   // expected-note@+4 {{non-constexpr function 'foobool' cannot be used in a constant expression}}
    149 #endif
    150 #pragma omp target
    151 #pragma omp teams
    152 #pragma omp distribute parallel for simd simdlen (foobool(argc)), simdlen (true), simdlen (-5) // expected-error {{expression is not an integral constant expression}} expected-error 2 {{directive '#pragma omp distribute parallel for simd' cannot contain more than one 'simdlen' clause}} expected-error 2 {{argument to 'simdlen' clause must be a strictly positive integer value}}
    153   for (int i = 4; i < 12; i++)
    154     argv[0][i] = argv[0][i] - argv[0][i-4];
    155 
    156 #pragma omp target
    157 #pragma omp teams
    158 #pragma omp distribute parallel for simd simdlen (S1) // expected-error {{'S1' does not refer to a value}}
    159   for (int i = 4; i < 12; i++)
    160     argv[0][i] = argv[0][i] - argv[0][i-4];
    161 
    162 #if __cplusplus <= 199711L
    163   // expected-error@+6 {{expression is not an integral constant expression}}
    164 #else
    165   // expected-error@+4 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
    166 #endif
    167 #pragma omp target
    168 #pragma omp teams
    169 #pragma omp distribute parallel for simd simdlen (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
    170   for (int i = 4; i < 12; i++)
    171     argv[0][i] = argv[0][i] - argv[0][i-4];
    172 
    173 #pragma omp target
    174 #pragma omp teams
    175 #pragma omp distribute parallel for simd simdlen(simdlen(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} expected-note {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
    176   foo(); // expected-error {{statement after '#pragma omp distribute parallel for simd' must be a for loop}}
    177 
    178   // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 12, 4>' requested here}}
    179   return tmain<int, char, 12, 4>(argc, argv);
    180 }
    181 
    182