brintos

brintos / llvm-project-archived public Read only

0
0
Text · 24.0 KiB · 1cc57c4 Raw
639 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp4,expectedw %s -Wuninitialized2// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp4,expectedw %s -Wuninitialized3// RUN: %clang_cc1 -fsyntax-only -fopenmp -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp5,expectedw %s -DOMP51 -Wuninitialized4// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp5,expectedw %s -DOMP51 -Wuninitialized5// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp4 %s -Wuninitialized -Wno-openmp-loop-form6// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp4 %s -Wuninitialized -Wno-openmp7 8static int sii;9// expected-note@+1 {{defined as threadprivate or thread local}}10#pragma omp threadprivate(sii)11static int globalii;12 13struct S {14  // expected-note@+1 {{static data member is predetermined as shared}}15  static int ssi;16};17 18int test_iteration_spaces() {19  const int N = 100;20  float a[N], b[N], c[N];21  int ii, jj, kk;22  float fii;23  double dii;24#pragma omp simd linear(S::ssi)25  for (S::ssi = 0; S::ssi < 10; ++S::ssi)26    ;27// expected-error@+1 {{shared variable cannot be private}}28#pragma omp simd private(S::ssi)29  for (S::ssi = 0; S::ssi < 10; ++S::ssi)30    ;31#pragma omp simd // no messages expected32  for (S::ssi = 0; S::ssi < 10; ++S::ssi)33    ;34  #pragma omp simd35  for (int i = 0; i < 10; i+=1) {36    c[i] = a[i] + b[i];37  }38  #pragma omp simd39  for (char i = 0; i < 10; i++) {40    c[i] = a[i] + b[i];41  }42  #pragma omp simd43  for (char i = 0; i < 10; i+='\1') {44    c[i] = a[i] + b[i];45  }46  #pragma omp simd47  for (long long i = 0; i < 10; i++) {48    c[i] = a[i] + b[i];49  }50  // expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'double'}}51  #pragma omp simd52  for (long long i = 0; i < 10; i+=1.5) {53    c[i] = a[i] + b[i];54  }55  #pragma omp simd56  for (long long i = 0; i < 'z'; i+=1u) {57    c[i] = a[i] + b[i];58  }59  // expected-error@+2 {{variable must be of integer or random access iterator type}}60  #pragma omp simd61  for (float fi = 0; fi < 10.0; fi++) {62    c[(int)fi] = a[(int)fi] + b[(int)fi];63  }64  // expected-error@+2 {{variable must be of integer or random access iterator type}}65  #pragma omp simd66  for (double fi = 0; fi < 10.0; fi++) {67    c[(int)fi] = a[(int)fi] + b[(int)fi];68  }69  // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}70  #pragma omp simd71  for (int &ref = ii; ref < 10; ref++) {72  }73  // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}74  #pragma omp simd75  for (int i; i < 10; i++)76    c[i] = a[i];77 78  // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}79  #pragma omp simd80  for (int i = 0, j = 0; i < 10; ++i)81    c[i] = a[i];82 83  // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}84  #pragma omp simd85  for (;ii < 10; ++ii)86    c[ii] = a[ii];87 88  // expected-warning@+3 {{expression result unused}}89  // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}90  #pragma omp simd91  for (ii + 1;ii < 10; ++ii)92    c[ii] = a[ii];93 94  // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}95  #pragma omp simd96  for (c[ii] = 0;ii < 10; ++ii)97    c[ii] = a[ii];98 99  // Ok to skip parenthesises.100  #pragma omp simd101  for (((ii)) = 0;ii < 10; ++ii)102    c[ii] = a[ii];103 104  // omp4-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} omp5-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}}105  #pragma omp simd106  for (int i = 0; i; i++)107    c[i] = a[i];108 109  // omp4-error@+3 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} omp5-error@+3 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}}110  // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'i'}}111  #pragma omp simd112  for (int i = 0; jj < kk; ii++)113    c[i] = a[i];114 115  // omp4-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} omp5-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}}116  #pragma omp simd117  for (int i = 0; !!i; i++)118    c[i] = a[i];119 120	// omp4-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}121  #pragma omp simd122  for (int i = 0; i != 1; i++)123    c[i] = a[i];124 125  // omp4-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} omp5-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}}126  #pragma omp simd127  for (int i = 0; ; i++)128    c[i] = a[i];129 130  // Ok.131  #pragma omp simd132  for (int i = 11; i > 10; i--)133    c[i] = a[i];134 135  // Ok.136  #pragma omp simd137  for (int i = 0; i < 10; ++i)138    c[i] = a[i];139 140    // Ok.141  #pragma omp simd142  for (ii = 0; ii < 10; ++ii)143    c[ii] = a[ii];144 145  // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}146  #pragma omp simd147  for (ii = 0; ii < 10; ++jj)148    c[ii] = a[jj];149 150  // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}151  #pragma omp simd152  for (ii = 0; ii < 10; ++ ++ ii)153    c[ii] = a[ii];154 155  // Ok but undefined behavior (in general, cannot check that incr156  // is really loop-invariant).157  #pragma omp simd158  for (ii = 0; ii < 10; ii = ii + ii)159    c[ii] = a[ii];160 161  // expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'float'}}162  #pragma omp simd163  for (ii = 0; ii < 10; ii = ii + 1.0f)164    c[ii] = a[ii];165 166  // Ok - step was converted to integer type.167  #pragma omp simd168  for (ii = 0; ii < 10; ii = ii + (int)1.1f)169    c[ii] = a[ii];170 171  // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}172  #pragma omp simd173  for (ii = 0; ii < 10; jj = ii + 2)174    c[ii] = a[ii];175 176  // expected-warning@+3 {{relational comparison result unused}}177  // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}178  #pragma omp simd179  for (ii = 0; ii < 10; jj > kk + 2)180    c[ii] = a[ii];181 182  // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}183  #pragma omp simd184  for (ii = 0; ii < 10;)185    c[ii] = a[ii];186 187  // expected-warning@+3 {{expression result unused}}188  // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}189  #pragma omp simd190  for (ii = 0; ii < 10; !ii)191    c[ii] = a[ii];192 193  // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}194  #pragma omp simd195  for (ii = 0; ii < 10; ii ? ++ii : ++jj)196    c[ii] = a[ii];197 198  // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}199  #pragma omp simd200  for (ii = 0; ii < 10; ii = ii < 10)201    c[ii] = a[ii];202 203  // expected-note@+3 {{loop step is expected to be positive due to this condition}}204  // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}205  #pragma omp simd206  for (ii = 0; ii < 10; ii = ii + 0)207    c[ii] = a[ii];208 209  // expected-note@+3 {{loop step is expected to be positive due to this condition}}210  // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}211  #pragma omp simd212  for (ii = 0; ii < 10; ii = ii + (int)(0.8 - 0.45))213    c[ii] = a[ii];214 215  // expected-note@+3 {{loop step is expected to be positive due to this condition}}216  // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}217  #pragma omp simd218  for (ii = 0; (ii) < 10; ii-=25)219    c[ii] = a[ii];220 221  // expected-note@+3 {{loop step is expected to be positive due to this condition}}222  // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}223  #pragma omp simd224  for (ii = 0; (ii < 10); ii-=0)225    c[ii] = a[ii];226 227  // expected-note@+3 {{loop step is expected to be negative due to this condition}}228  // expected-error@+2 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}229  #pragma omp simd230  for (ii = 0; ii > 10; (ii+=0))231    c[ii] = a[ii];232 233  // expected-note@+3 {{loop step is expected to be positive due to this condition}}234  // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}235  #pragma omp simd236  for (ii = 0; ii < 10; (ii) = (1-1)+(ii))237    c[ii] = a[ii];238 239  // expected-note@+3 {{loop step is expected to be negative due to this condition}}240  // expected-error@+2 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}241  #pragma omp simd242  for ((ii = 0); ii > 10; (ii-=0))243    c[ii] = a[ii];244 245  // expected-note@+3 {{loop step is expected to be positive due to this condition}}246  // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}247  #pragma omp simd248  for (ii = 0; (ii < 10); (ii-=0))249    c[ii] = a[ii];250 251#ifndef OMP51252  // expected-note@+3  {{defined as private}}253  // expected-error@+3 {{loop iteration variable in the associated loop of 'omp simd' directive may not be private, predetermined as linear}}254#endif // OMP51255  #pragma omp simd private(ii)256  for (ii = 0; ii < 10; ii++)257    c[ii] = a[ii];258 259#ifndef OMP51260  // expected-note@+3  {{defined as lastprivate}}261  // expected-error@+3 {{loop iteration variable in the associated loop of 'omp simd' directive may not be lastprivate, predetermined as linear}}262#endif // OMP51263  #pragma omp simd lastprivate(ii)264  for (ii = 0; ii < 10; ii++)265    c[ii] = a[ii];266 267  // expected-error@+1 {{unexpected OpenMP clause 'shared' in directive '#pragma omp simd'}}268  #pragma omp simd shared(ii)269  for (ii = 0; ii < 10; ii++)270    c[ii] = a[ii];271 272  #pragma omp simd linear(ii)273  for (ii = 0; ii < 10; ii++)274    c[ii] = a[ii];275 276  #pragma omp simd lastprivate(ii) linear(jj) collapse(2) // expected-note {{defined as linear}}277  for (ii = 0; ii < 10; ii++)278  for (jj = 0; jj < 10; jj++) // expected-error {{loop iteration variable in the associated loop of 'omp simd' directive may not be linear, predetermined as lastprivate}}279    c[ii] = a[jj];280 281 282  #pragma omp parallel283  {284// expected-error@+2 {{loop iteration variable in the associated loop of 'omp simd' directive may not be threadprivate or thread local, predetermined as linear}}285    #pragma omp simd286    for (sii = 0; sii < 10; sii+=1)287      c[sii] = a[sii];288  }289 290  #pragma omp parallel291  {292    #pragma omp simd293    for (globalii = 0; globalii < 10; globalii+=1)294      c[globalii] = a[globalii];295  }296 297  #pragma omp parallel298  {299#pragma omp simd collapse(2)300    for (ii = 0; ii < 10; ii += 1)301    for (globalii = 0; globalii < 10; globalii += 1)302      c[globalii] += a[globalii] + ii;303  }304 305  // omp4-error@+2 {{statement after '#pragma omp simd' must be a for loop}}306  #pragma omp simd307  for (auto &item : a) {308    item = item + 1;309  }310 311  // expected-note@+3 {{loop step is expected to be positive due to this condition}}312  // expected-error@+2 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}}313  #pragma omp simd314  for (unsigned i = 9; i < 10; i--) {315    c[i] = a[i] + b[i];316  }317 318  int (*lb)[4] = nullptr;319  #pragma omp simd320  for (int (*p)[4] = lb; p < lb + 8; ++p) {321  }322 323  // expectedw-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}324  #pragma omp simd325  for (int a{0}; a<10; ++a) {326  }327 328  return 0;329}330 331// Iterators allowed in openmp for-loops.332namespace std {333struct random_access_iterator_tag { };334template <class Iter> struct iterator_traits {335  typedef typename Iter::difference_type difference_type;336  typedef typename Iter::iterator_category iterator_category;337};338template <class Iter>339typename iterator_traits<Iter>::difference_type340distance(Iter first, Iter last) { return first - last; }341}342class Iter0 {343  public:344    Iter0() { }345    Iter0(const Iter0 &) { }346    Iter0 operator ++() { return *this; }347    Iter0 operator --() { return *this; }348    Iter0 operator + (int delta) { return *this; }349    bool operator <(Iter0 a) { return true; }350};351// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'Iter0' for 1st argument}}352int operator -(Iter0 a, Iter0 b) { return 0; }353class Iter1 {354  public:355    Iter1(float f=0.0f, double d=0.0) { }356    Iter1(const Iter1 &) { }357    Iter1 operator ++() { return *this; }358    Iter1 operator --() { return *this; }359    bool operator <(Iter1 a) { return true; }360    bool operator >=(Iter1 a) { return false; }361};362class GoodIter {363  public:364    GoodIter() { }365    GoodIter(const GoodIter &) { }366    GoodIter(int fst, int snd) { }367    GoodIter &operator =(const GoodIter &that) { return *this; }368    GoodIter &operator =(const Iter0 &that) { return *this; }369    GoodIter &operator +=(int x) { return *this; }370    explicit GoodIter(void *) { }371    GoodIter operator ++() { return *this; }372    GoodIter operator --() { return *this; }373    bool operator !() { return true; }374    bool operator <(GoodIter a) { return true; }375    bool operator <=(GoodIter a) { return true; }376    bool operator >=(GoodIter a) { return false; }377    typedef int difference_type;378    typedef std::random_access_iterator_tag iterator_category;379};380// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}381int operator -(GoodIter a, GoodIter b) { return 0; }382// expected-note@+1 2 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}}383GoodIter operator -(GoodIter a) { return a; }384// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}385GoodIter operator -(GoodIter a, int v) { return GoodIter(); }386GoodIter operator +(GoodIter a, int v) { return GoodIter(); }387// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'int' for 1st argument}}388GoodIter operator -(int v, GoodIter a) { return GoodIter(); }389GoodIter operator +(int v, GoodIter a) { return GoodIter(); }390 391int test_with_random_access_iterator() {392  GoodIter begin, end;393  Iter0 begin0, end0;394  #pragma omp simd395  for (GoodIter I = begin; I < end; ++I)396    ++I;397  // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}398  #pragma omp simd399  for (GoodIter &I = begin; I < end; ++I)400    ++I;401  #pragma omp simd402  for (GoodIter I = begin; I >= end; --I)403    ++I;404  // expectedw-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}405  #pragma omp simd406  for (GoodIter I(begin); I < end; ++I)407    ++I;408  // expectedw-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}409  #pragma omp simd410  for (GoodIter I(nullptr); I < end; ++I)411    ++I;412  // expectedw-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}413  #pragma omp simd414  for (GoodIter I(0); I < end; ++I)415    ++I;416  // expectedw-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}417  #pragma omp simd418  for (GoodIter I(1,2); I < end; ++I)419    ++I;420  #pragma omp simd421  for (begin = GoodIter(0); begin < end; ++begin)422    ++begin;423  #pragma omp simd424  for (begin = GoodIter(1,2); begin < end; ++begin)425    ++begin;426  // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}427  #pragma omp simd428  for (++begin; begin < end; ++begin)429    ++begin;430  #pragma omp simd431  for (begin = end; begin < end; ++begin)432    ++begin;433  // omp4-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} omp5-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'I'}}434  #pragma omp simd435  for (GoodIter I = begin; I - I; ++I)436    ++I;437  // omp4-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} omp5-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'I'}}438  #pragma omp simd439  for (GoodIter I = begin; begin < end; ++I)440    ++I;441  // omp4-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} omp5-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'I'}}442  #pragma omp simd443  for (GoodIter I = begin; !I; ++I)444    ++I;445  // expected-note@+3 {{loop step is expected to be negative due to this condition}}446  // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}447  #pragma omp simd448  for (GoodIter I = begin; I >= end; I = I + 1)449    ++I;450  #pragma omp simd451  for (GoodIter I = begin; I >= end; I = I - 1)452    ++I;453  // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}454  #pragma omp simd455  for (GoodIter I = begin; I >= end; I = -I)456    ++I;457  // expected-note@+3 {{loop step is expected to be negative due to this condition}}458  // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}459  #pragma omp simd460  for (GoodIter I = begin; I >= end; I = 2 + I)461    ++I;462  // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}463  #pragma omp simd464  for (GoodIter I = begin; I >= end; I = 2 - I)465    ++I;466  #pragma omp simd467  for (Iter0 I = begin0; I < end0; ++I)468    ++I;469 470  // Initializer is constructor without params.471  // expectedw-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}472  #pragma omp simd473  for (Iter0 I; I < end0; ++I)474    ++I;475 476  Iter1 begin1, end1;477  // expected-error@+3 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}478  // expected-error@+2 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}479  #pragma omp simd480  for (Iter1 I = begin1; I < end1; ++I)481    ++I;482  // expected-note@+3 {{loop step is expected to be negative due to this condition}}483  // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}484  #pragma omp simd485  for (Iter1 I = begin1; I >= end1; ++I)486    ++I;487 488  // Initializer is constructor with all default params.489  // expected-error@+4 {{invalid operands to binary expression ('Iter1' and 'float')}}490  // expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}491  // expectedw-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}492  #pragma omp simd493  for (Iter1 I; I < end1; ++I) {494  }495 496  return 0;497}498 499template <typename IT, int ST> class TC {500  public:501    int dotest_lt(IT begin, IT end) {502      // expected-note@+3 {{loop step is expected to be positive due to this condition}}503      // expected-error@+2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}504      #pragma omp simd505      for (IT I = begin; I < end; I = I + ST) {506        ++I;507      }508      // expected-note@+3 {{loop step is expected to be positive due to this condition}}509      // expected-error@+2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}510      #pragma omp simd511      for (IT I = begin; I <= end; I += ST) {512        ++I;513      }514      #pragma omp simd515      for (IT I = begin; I < end; ++I) {516        ++I;517      }518    }519 520    static IT step() {521      return IT(ST);522    }523};524template <typename IT, int ST=0> int dotest_gt(IT begin, IT end) {525  // expected-note@+3 2 {{loop step is expected to be negative due to this condition}}526  // expected-error@+2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}527  #pragma omp simd528  for (IT I = begin; I >= end; I = I + ST) {529    ++I;530  }531  // expected-note@+3 2 {{loop step is expected to be negative due to this condition}}532  // expected-error@+2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}533  #pragma omp simd534  for (IT I = begin; I >= end; I += ST) {535    ++I;536  }537 538  // expected-note@+3 {{loop step is expected to be negative due to this condition}}539  // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}540  #pragma omp simd541  for (IT I = begin; I >= end; ++I) {542    ++I;543  }544 545  #pragma omp simd546  for (IT I = begin; I < end; I+=TC<int,ST>::step()) {547    ++I;548  }549}550 551void test_with_template() {552  GoodIter begin, end;553  TC<GoodIter, 100> t1;554  TC<GoodIter, -100> t2;555  t1.dotest_lt(begin, end);556  t2.dotest_lt(begin, end); // expected-note {{in instantiation of member function 'TC<GoodIter, -100>::dotest_lt' requested here}}557  dotest_gt(begin, end); // expected-note {{in instantiation of function template specialization 'dotest_gt<GoodIter, 0>' requested here}}558  dotest_gt<unsigned, 10>(0, 100); // expected-note {{in instantiation of function template specialization 'dotest_gt<unsigned int, 10>' requested here}}559}560 561void test_loop_break() {562  const int N = 100;563  float a[N], b[N], c[N];564  #pragma omp simd565  for (int i = 0; i < 10; i++) {566    c[i] = a[i] + b[i];567    for (int j = 0; j < 10; ++j) {568      if (a[i] > b[j])569        break; // OK in nested loop570    }571    switch(i) {572      case 1:573        b[i]++;574        break;575      default:576        break;577    }578    if (c[i] > 10)579      break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}580 581    if (c[i] > 11)582      break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}583  }584 585  #pragma omp simd586  for (int i = 0; i < 10; i++) {587    for (int j = 0; j < 10; j++) {588      c[i] = a[i] + b[i];589      if (c[i] > 10) {590        if (c[i] < 20) {591          break; // OK592        }593      }594    }595  }596}597 598void test_loop_eh() {599  const int N = 100;600  float a[N], b[N], c[N];601  #pragma omp simd602  for (int i = 0; i < 10; i++) {603    c[i] = a[i] + b[i];604    try { // expected-error {{'try' statement cannot be used in OpenMP simd region}}605      for (int j = 0; j < 10; ++j) {606        if (a[i] > b[j])607          throw a[i]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}608      }609      throw a[i]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}610    }611    catch (float f) {612      if (f > 0.1)613        throw a[i]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}614      return; // expected-error {{cannot return from OpenMP region}}615    }616    switch(i) {617      case 1:618        b[i]++;619        break;620      default:621        break;622    }623    for (int j = 0; j < 10; j++) {624      if (c[i] > 10)625        throw c[i]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}626    }627  }628  if (c[9] > 10)629    throw c[9]; // OK630 631  #pragma omp simd632  for (int i = 0; i < 10; ++i) {633    struct S {634      void g() { throw 0; }635    };636  }637}638 639