brintos

brintos / llvm-project-archived public Read only

0
0
Text · 13.5 KiB · 08d745f Raw
371 lines · cpp
1// RUN: %clang_cc1 -verify -fopenmp %s -Wno-openmp-mapping -Wuninitialized2// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 -DOMP52 %s -Wno-openmp-mapping -Wuninitialized3 4// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wno-openmp-mapping -Wuninitialized5// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp-simd -fopenmp-version=52 -DOMP52 %s -Wno-openmp-mapping -Wuninitialized6 7extern int omp_default_mem_alloc;8 9void xxx(int argc) {10  int i;11#pragma omp distribute parallel for simd linear(i)12  for (i = 0; i < 10; ++i)13    ;14}15 16namespace X {17  int x;18};19 20struct B {21  static int ib; // expected-note {{'B::ib' declared here}}22  static int bfoo() { return 8; }23};24 25int bfoo() { return 4; }26 27int z;28const int C1 = 1;29const int C2 = 2;30void test_linear_colons()31{32  int B = 0;33 34// expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}35#pragma omp target36#pragma omp teams37#pragma omp distribute parallel for simd linear(B:bfoo())38  for (int i = 0; i < 10; ++i) ;39 40// expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}41#pragma omp target42#pragma omp teams43#pragma omp distribute parallel for simd linear(B::ib:B:bfoo()) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'}}44  for (int i = 0; i < 10; ++i) ;45 46// expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}47#pragma omp target48#pragma omp teams49#pragma omp distribute parallel for simd linear(B:ib) // expected-error {{use of undeclared identifier 'ib'; did you mean 'B::ib'}}50  for (int i = 0; i < 10; ++i) ;51 52// expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}53#pragma omp target54#pragma omp teams55#pragma omp distribute parallel for simd linear(z:B:ib) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}}56  for (int i = 0; i < 10; ++i) ;57 58// expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}59#pragma omp target60#pragma omp teams61#pragma omp distribute parallel for simd linear(B:B::bfoo())62  for (int i = 0; i < 10; ++i) ;63 64// expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}65#pragma omp target66#pragma omp teams67#pragma omp distribute parallel for simd linear(X::x : ::z)68  for (int i = 0; i < 10; ++i) ;69 70// expected-error@+3 3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}71#pragma omp target72#pragma omp teams73#pragma omp distribute parallel for simd linear(B,::z, X::x)74  for (int i = 0; i < 10; ++i) ;75 76// expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}77#pragma omp target78#pragma omp teams79#pragma omp distribute parallel for simd linear(::z)80  for (int i = 0; i < 10; ++i) ;81 82#pragma omp target83#pragma omp teams84#pragma omp distribute parallel for simd linear(B::bfoo()) // expected-error {{expected variable name}}85  for (int i = 0; i < 10; ++i) ;86 87// expected-error@+3 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}88#pragma omp target89#pragma omp teams90#pragma omp distribute parallel for simd linear(B::ib,B:C1+C2)91  for (int i = 0; i < 10; ++i) ;92}93 94template<int L, class T, class N> T test_template(T* arr, N num) {95  N i;96  T sum = (T)0;97  T ind2 = - num * L; // expected-note {{'ind2' defined here}}98 99#pragma omp target100#pragma omp teams101#pragma omp distribute parallel for simd linear(ind2:L) // expected-error {{argument of a linear clause should be of integral or pointer type}}102  for (i = 0; i < num; ++i) {103    T cur = arr[(int)ind2];104    ind2 += L;105    sum += cur;106  }107  return T();108}109 110template<int LEN> int test_warn() {111  int ind2 = 0;112  #pragma omp target113  #pragma omp teams114  #pragma omp parallel for simd linear(ind2:LEN) // expected-warning {{zero linear step ('ind2' should probably be const)}}115  for (int i = 0; i < 100; i++) {116    ind2 += LEN;117  }118  return ind2;119}120 121struct S1; // expected-note 2 {{declared here}} expected-note 3 {{forward declaration of 'S1'}}122extern S1 a;123class S2 {124  mutable int a;125public:126  S2():a(0) { }127};128const S2 b; // expected-note 2 {{'b' defined here}}129const S2 ba[5];130class S3 {131  int a;132public:133  S3():a(0) { }134};135const S3 ca[5];136class S4 {137  int a;138  S4();139public:140  S4(int v):a(v) { }141};142class S5 {143  int a;144  S5():a(0) {}145public:146  S5(int v):a(v) { }147};148 149S3 h;150#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}151 152template<class I, class C> int foomain(I argc, C **argv) {153  I e(4);154  I g(5);155  int i;156  int &j = i;157 158#pragma omp target159#pragma omp teams160#pragma omp distribute parallel for simd linear // expected-error {{expected '(' after 'linear'}}161  for (int k = 0; k < argc; ++k) ++k;162 163#pragma omp target164#pragma omp teams165#pragma omp distribute parallel for simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}166  for (int k = 0; k < argc; ++k) ++k;167 168#pragma omp target169#pragma omp teams170#pragma omp distribute parallel for simd linear () // expected-error {{expected expression}}171  for (int k = 0; k < argc; ++k) ++k;172 173// expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}174#pragma omp target175#pragma omp teams176#pragma omp distribute parallel for simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}177  for (int k = 0; k < argc; ++k) ++k;178 179// expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}180#pragma omp target181#pragma omp teams182#pragma omp distribute parallel for simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}183  for (int k = 0; k < argc; ++k) ++k;184 185#pragma omp target186#pragma omp teams187#pragma omp distribute parallel for simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}188  for (int k = 0; k < argc; ++k) ++k;189 190// expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}191#pragma omp target192#pragma omp teams193#pragma omp distribute parallel for simd linear (argc : 5)194  for (int k = 0; k < argc; ++k) ++k;195 196#pragma omp target197#pragma omp teams198#pragma omp distribute parallel for simd linear (S1) // expected-error {{'S1' does not refer to a value}}199  for (int k = 0; k < argc; ++k) ++k;200 201#pragma omp target202#pragma omp teams203#pragma omp distribute parallel for simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}}204  for (int k = 0; k < argc; ++k) ++k;205 206#pragma omp target207#pragma omp teams208#pragma omp distribute parallel for simd linear (argv[1]) // expected-error {{expected variable name}}209  for (int k = 0; k < argc; ++k) ++k;210 211// expected-error@+3 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}212#pragma omp target213#pragma omp teams214#pragma omp distribute parallel for simd linear(e, g)215  for (int k = 0; k < argc; ++k) ++k;216 217#pragma omp target218#pragma omp teams219#pragma omp distribute parallel for simd linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}}220  for (int k = 0; k < argc; ++k) ++k;221 222// expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}223#pragma omp target224#pragma omp teams225#pragma omp distribute parallel for simd linear(i)226  for (int k = 0; k < argc; ++k) ++k;227 228  #pragma omp parallel229  {230    int v = 0;231    int i;232    int k;233    #pragma omp target234    #pragma omp teams235    #pragma omp distribute parallel for simd linear(k:i)236    for (k = 0; k < argc; ++k) { i = k; v += i; }237  }238 239  return 0;240}241 242namespace A {243double x;244#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}245}246namespace C {247using A::x;248}249 250int main(int argc, char **argv) {251  double darr[100];252  // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}253  test_template<-4>(darr, 4);254  // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}255  test_warn<0>();256 257  S4 e(4); // expected-note {{'e' defined here}}258  S5 g(5); // expected-note {{'g' defined here}}259  int i;260  int &j = i;261 262#pragma omp target263#pragma omp teams264#pragma omp distribute parallel for simd linear // expected-error {{expected '(' after 'linear'}}265  for (int k = 0; k < argc; ++k) ++k;266 267#pragma omp target268#pragma omp teams269#pragma omp distribute parallel for simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}270  for (int k = 0; k < argc; ++k) ++k;271 272#pragma omp target273#pragma omp teams274#pragma omp distribute parallel for simd linear () // expected-error {{expected expression}}275  for (int k = 0; k < argc; ++k) ++k;276 277// expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}278#pragma omp target279#pragma omp teams280#pragma omp distribute parallel for simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}281  for (int k = 0; k < argc; ++k) ++k;282 283// expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}284#pragma omp target285#pragma omp teams286#pragma omp distribute parallel for simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}287  for (int k = 0; k < argc; ++k) ++k;288 289#pragma omp target290#pragma omp teams291#pragma omp distribute parallel for simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}292  for (int k = 0; k < argc; ++k) ++k;293 294// expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}295#pragma omp target296#pragma omp teams297#pragma omp distribute parallel for simd linear (argc) allocate , allocate(, allocate(omp_default , allocate(omp_default_mem_alloc, allocate(omp_default_mem_alloc:, allocate(omp_default_mem_alloc: argc, allocate(omp_default_mem_alloc: argv), allocate(argv) // expected-error {{expected '(' after 'allocate'}} expected-error 2 {{expected expression}} expected-error 2 {{expected ')'}} expected-error {{use of undeclared identifier 'omp_default'}} expected-note 2 {{to match this '('}}298  for (int k = 0; k < argc; ++k) ++k;299 300#pragma omp target301#pragma omp teams302#pragma omp distribute parallel for simd linear (S1) // expected-error {{'S1' does not refer to a value}}303  for (int k = 0; k < argc; ++k) ++k;304 305 306#pragma omp target307#pragma omp teams308#pragma omp distribute parallel for simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}} expected-error {{incomplete type 'S1' where a complete type is required}}309  for (int k = 0; k < argc; ++k) ++k;310 311#pragma omp target312#pragma omp teams313#pragma omp distribute parallel for simd linear (argv[1]) // expected-error {{expected variable name}}314  for (int k = 0; k < argc; ++k) ++k;315 316#pragma omp target317#pragma omp teams318#pragma omp distribute parallel for simd linear(e, g) // expected-error {{argument of a linear clause should be of integral or pointer type, not 'S4'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S5'}}319  for (int k = 0; k < argc; ++k) ++k;320 321#pragma omp target322#pragma omp teams323#pragma omp distribute parallel for simd linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}}324  for (int k = 0; k < argc; ++k) ++k;325 326  #pragma omp parallel327  {328    int i;329    #pragma omp target330    #pragma omp teams331    #pragma omp distribute parallel for simd linear(i)332      for (i = 0; i < argc; ++i) ++i;333 334    #pragma omp target335    #pragma omp teams336    #pragma omp distribute parallel for simd linear(i : 4)337      for (i = 0; i < argc; ++i) { ++i; i += 4; }338 339#ifdef OMP52340    #pragma omp target341    #pragma omp teams342    #pragma omp distribute parallel for simd linear(i: step() //omp52-error 2 {{expected expression}} omp52-error{{expected ')'}} omp52-note{{to match this '('}}343      for (i = 0; i < argc; ++i) ++i;344    #pragma omp target345    #pragma omp teams346    #pragma omp distribute parallel for simd linear(i: step(1), step(2)) // omp52-error {{multiple 'step size' found in linear clause}}347      for (i = 0; i < argc; ++i) ++i;348    #pragma omp target349    #pragma omp teams350    #pragma omp distribute parallel for simd linear(i: val, val) // omp52-error {{multiple 'linear modifier' found in linear clause}}351      for (i = 0; i < argc; ++i) ++i;352    #pragma omp target353    #pragma omp teams354    #pragma omp distribute parallel for simd linear(i: step()) // omp52-error 2 {{expected expression}}355      for (i = 0; i < argc; ++i) ++i;356    #pragma omp target357    #pragma omp teams358    #pragma omp distribute parallel for simd linear(i: pval) // omp52-error {{use of undeclared identifier 'pval'}}359      for (i = 0; i < argc; ++i) ++i;360    #pragma omp target361    #pragma omp teams362    #pragma omp distribute parallel for simd linear(i: val, step(2 // omp52-error {{expected ')' or ',' after 'step expression'}} omp52-error 2 {{expected ')'}}  omp52-note 2 {{to match this '('}}363      for (i = 0; i < argc; ++i) ++i;364#endif365  }366 367  foomain<int,char>(argc,argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}368  return 0;369}370 371