Home | History | Annotate | Download | only in OpenMP
      1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
      2 
      3 void foo() {
      4 }
      5 
      6 bool foobool(int argc) {
      7   return argc;
      8 }
      9 
     10 struct S1; // expected-note 2 {{declared here}}
     11 extern S1 a;
     12 class S2 {
     13   mutable int a;
     14 public:
     15   S2():a(0) { }
     16   S2(S2 &s2):a(s2.a) { }
     17   static float S2s; // expected-note 4 {{mappable type cannot contain static members}}
     18   static const float S2sc; // expected-note 4 {{mappable type cannot contain static members}}
     19 };
     20 const float S2::S2sc = 0;
     21 const S2 b;
     22 const S2 ba[5];
     23 class S3 {
     24   int a;
     25 public:
     26   S3():a(0) { }
     27   S3(S3 &s3):a(s3.a) { }
     28 };
     29 const S3 c;
     30 const S3 ca[5];
     31 extern const int f;
     32 class S4 {
     33   int a;
     34   S4();
     35   S4(const S4 &s4);
     36 public:
     37   S4(int v):a(v) { }
     38 };
     39 class S5 {
     40   int a;
     41   S5():a(0) {}
     42   S5(const S5 &s5):a(s5.a) { }
     43 public:
     44   S5(int v):a(v) { }
     45 };
     46 
     47 S3 h;
     48 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
     49 
     50 typedef int from;
     51 
     52 template <typename T, int I> // expected-note {{declared here}}
     53 T tmain(T argc) {
     54   const T d = 5;
     55   const T da[5] = { 0 };
     56   S4 e(4);
     57   S5 g(5);
     58   T i, t[20];
     59   T &j = i;
     60   T *k = &j;
     61   T x;
     62   T y;
     63   T to, tofrom, always;
     64   const T (&l)[5] = da;
     65 
     66 
     67 #pragma omp target map // expected-error {{expected '(' after 'map'}}
     68 #pragma omp target map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
     69 #pragma omp target map() // expected-error {{expected expression}}
     70 #pragma omp target map(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
     71 #pragma omp target map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}}
     72 #pragma omp target map(to:) // expected-error {{expected expression}}
     73 #pragma omp target map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     74 #pragma omp target map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
     75 #pragma omp target map(x)
     76   foo();
     77 #pragma omp target map(tofrom: t[:I])
     78   foo();
     79 #pragma omp target map(T: a) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
     80   foo();
     81 #pragma omp target map(T) // expected-error {{'T' does not refer to a value}}
     82   foo();
     83 #pragma omp target map(I) // expected-error 2 {{expected variable name, array element or array section}}
     84   foo();
     85 #pragma omp target map(S2::S2s)
     86   foo();
     87 #pragma omp target map(S2::S2sc)
     88   foo();
     89 #pragma omp target map(x)
     90   foo();
     91 #pragma omp target map(to: x)
     92   foo();
     93 #pragma omp target map(to: to)
     94   foo();
     95 #pragma omp target map(to)
     96   foo();
     97 #pragma omp target map(to, x)
     98   foo();
     99 #pragma omp target map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
    100 #pragma omp target map(tofrom: argc > 0 ? x : y) // expected-error 2 {{expected variable name, array element or array section}}
    101 #pragma omp target map(argc)
    102 #pragma omp target map(S1) // expected-error {{'S1' does not refer to a value}}
    103 #pragma omp target map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} expected-error 2 {{type 'S2' is not mappable to target}}
    104 #pragma omp target map(ba) // expected-error 2 {{type 'S2' is not mappable to target}}
    105 #pragma omp target map(ca)
    106 #pragma omp target map(da)
    107 #pragma omp target map(S2::S2s)
    108 #pragma omp target map(S2::S2sc)
    109 #pragma omp target map(e, g)
    110 #pragma omp target map(h) // expected-error {{threadprivate variables are not allowed in map clause}}
    111 #pragma omp target map(k), map(k) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}}
    112 #pragma omp target map(k), map(k[:5]) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}}
    113   foo();
    114 #pragma omp target map(da)
    115 #pragma omp target map(da[:4])
    116   foo();
    117 #pragma omp target map(k, j, l) // expected-note 4 {{used here}}
    118 #pragma omp target map(k[:4]) // expected-error 2 {{variable already marked as mapped in current construct}}
    119 #pragma omp target map(j)
    120 #pragma omp target map(l[:5]) // expected-error 2 {{variable already marked as mapped in current construct}}
    121   foo();
    122 #pragma omp target map(k[:4], j, l[:5]) // expected-note 4 {{used here}}
    123 #pragma omp target map(k) // expected-error 2 {{variable already marked as mapped in current construct}}
    124 #pragma omp target map(j)
    125 #pragma omp target map(l) // expected-error 2 {{variable already marked as mapped in current construct}}
    126   foo();
    127 
    128 #pragma omp target map(always, tofrom: x)
    129 #pragma omp target map(always: x) // expected-error {{missing map type}}
    130 #pragma omp target map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always'}} expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
    131 #pragma omp target map(always, tofrom: always, tofrom, x)
    132 #pragma omp target map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
    133   foo();
    134 
    135   return 0;
    136 }
    137 
    138 int main(int argc, char **argv) {
    139   const int d = 5;
    140   const int da[5] = { 0 };
    141   S4 e(4);
    142   S5 g(5);
    143   int i;
    144   int &j = i;
    145   int *k = &j;
    146   int x;
    147   int y;
    148   int to, tofrom, always;
    149   const int (&l)[5] = da;
    150 #pragma omp target map // expected-error {{expected '(' after 'map'}}
    151 #pragma omp target map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
    152 #pragma omp target map() // expected-error {{expected expression}}
    153 #pragma omp target map(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
    154 #pragma omp target map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}}
    155 #pragma omp target map(to:) // expected-error {{expected expression}}
    156 #pragma omp target map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
    157 #pragma omp target map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
    158 #pragma omp target map(x)
    159   foo();
    160 #pragma omp target map(to: x)
    161   foo();
    162 #pragma omp target map(to: to)
    163   foo();
    164 #pragma omp target map(to)
    165   foo();
    166 #pragma omp target map(to, x)
    167   foo();
    168 #pragma omp target map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
    169 #pragma omp target map(tofrom: argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}}
    170 #pragma omp target map(argc)
    171 #pragma omp target map(S1) // expected-error {{'S1' does not refer to a value}}
    172 #pragma omp target map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} expected-error 2 {{type 'S2' is not mappable to target}}
    173 #pragma omp target map(argv[1])
    174 #pragma omp target map(ba) // expected-error 2 {{type 'S2' is not mappable to target}}
    175 #pragma omp target map(ca)
    176 #pragma omp target map(da)
    177 #pragma omp target map(S2::S2s)
    178 #pragma omp target map(S2::S2sc)
    179 #pragma omp target map(e, g)
    180 #pragma omp target map(h) // expected-error {{threadprivate variables are not allowed in map clause}}
    181 #pragma omp target map(k), map(k) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}}
    182 #pragma omp target map(k), map(k[:5]) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}}
    183   foo();
    184 #pragma omp target map(da)
    185 #pragma omp target map(da[:4])
    186   foo();
    187 #pragma omp target map(k, j, l) // expected-note 2 {{used here}}
    188 #pragma omp target map(k[:4]) // expected-error {{variable already marked as mapped in current construct}}
    189 #pragma omp target map(j)
    190 #pragma omp target map(l[:5]) // expected-error {{variable already marked as mapped in current construct}}
    191   foo();
    192 #pragma omp target map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
    193 #pragma omp target map(k) // expected-error {{variable already marked as mapped in current construct}}
    194 #pragma omp target map(j)
    195 #pragma omp target map(l) // expected-error {{variable already marked as mapped in current construct}}
    196   foo();
    197 
    198 #pragma omp target map(always, tofrom: x)
    199 #pragma omp target map(always: x) // expected-error {{missing map type}}
    200 #pragma omp target map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always'}} expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
    201 #pragma omp target map(always, tofrom: always, tofrom, x)
    202 #pragma omp target map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
    203   foo();
    204 
    205   return tmain<int, 3>(argc)+tmain<from, 4>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<int, 4>' requested here}}
    206 }
    207 
    208