brintos

brintos / llvm-project-archived public Read only

0
0
Text · 16.0 KiB · e7ca0ee Raw
393 lines · cpp
1// RUN: %clang_cc1 %s -fopenacc -verify -Wno-empty-body -Wno-unused-value2namespace std {3  struct random_access_iterator_tag{};4}5 6struct SomeStruct{7  void operator++();8  void operator++(int);9};10 11struct SomeIterator {12  bool operator!=(SomeIterator&);13  void operator++();14  void operator++(int);15  int operator*();16};17 18struct SomeRAIterator {19  using iterator_category = std::random_access_iterator_tag;20  SomeRAIterator();21  SomeRAIterator(int i);22 23  void operator=(int i);24  SomeRAIterator &operator=(SomeRAIterator&);25 26  void operator++(int);27  void operator++();28  int operator*();29  void operator+=(int);30  bool operator!=(SomeRAIterator&);31};32 33struct HasIteratorCollection {34  SomeIterator &begin();35  SomeIterator &end();36};37 38struct HasRAIteratorCollection {39  SomeRAIterator &begin();40  SomeRAIterator &end();41};42 43void func_call();44 45template<typename Int, typename IntPtr, typename Float, typename Struct, typename Iterator, typename RandAccessIterator>46void SeqLoopRules() {47 48  // expected-error@+3{{OpenACC 'parallel loop' construct can only be applied to a 'for' loop}}49  // expected-note@+1{{'parallel loop' construct is here}}50#pragma acc parallel loop seq51  while(true);52 53  // No rules in this section!54#pragma acc kernels loop seq55  for(;;);56 57#pragma acc parallel loop seq58  for(float f = 0;;);59 60#pragma acc serial loop seq61  for(int f;;);62 63#pragma acc kernels loop seq64  for(int f,g;;);65 66#pragma acc parallel loop seq67  for(Int f;;++f);68 69#pragma acc serial loop seq70  for(Int *f = nullptr;;++f);71 72#pragma acc kernels loop seq73  for(IntPtr f = nullptr;;++f);74 75#pragma acc parallel loop seq76  for(Float *f = nullptr;;++f);77 78#pragma acc serial loop seq79  for(SomeStruct f;;);80 81#pragma acc kernels loop seq82  for(Struct f;;++f);83 84#pragma acc parallel loop seq85  for(SomeIterator f;;++f);86 87#pragma acc serial loop seq88  for(Iterator f;;++f);89 90#pragma acc kernels loop seq91  for(SomeRAIterator f;;++f);92 93#pragma acc parallel loop seq94  for(RandAccessIterator f;;++f);95 96#pragma acc kernels loop seq97  for(Int f;;);98 99#pragma acc parallel loop seq100  for(Int f;;++f);101 102#pragma acc serial loop seq103  for(Int f;;f+=1);104 105  int i;106#pragma acc kernels loop seq107  for(Int f;;i+=1);108 109#pragma acc parallel loop seq110  for(Int f;;i++);111 112#pragma acc serial loop seq113  for(RandAccessIterator f;;i++);114 115#pragma acc kernels loop seq116  for(RandAccessIterator f;;func_call());117 118  Int Array[5];119#pragma acc parallel loop seq120  for(auto X : Array);121 122#pragma acc serial loop seq123  for(auto X : HasIteratorCollection{});124 125#pragma acc kernels loop seq126  for(auto X : HasRAIteratorCollection{});127 128  RandAccessIterator f, end;129#pragma acc parallel loop seq130  for(f;f != end;f++);131 132#pragma acc kernels loop seq133  for(f = 0;;++f);134 135#pragma acc parallel loop seq136  for(f = 0;;f++);137 138#pragma acc serial loop seq139  for(f = 0;;f+=1);140}141 142 143template<typename Int, typename IntPtr, typename Float, typename Struct, typename Iterator, typename RandAccessIterator>144void LoopRules() {145  // expected-error@+3{{OpenACC 'parallel loop' construct can only be applied to a 'for' loop}}146  // expected-note@+1{{'parallel loop' construct is here}}147#pragma acc parallel loop148  while(true);149 150  // Loop variable must be integer, pointer, or random_access_iterator151#pragma acc kernels loop152  // expected-error@+6{{OpenACC 'kernels loop' construct must have initialization clause in canonical form ('var = init' or 'T var = init'}}153  // expected-note@-2{{'kernels loop' construct is here}}154  // expected-error@+4{{OpenACC 'kernels loop' construct must have a terminating condition}}155  // expected-note@-4{{'kernels loop' construct is here}}156  // expected-error@+2{{OpenACC 'kernels loop' variable must monotonically increase or decrease ('++', '--', or compound assignment)}}157  // expected-note@-6{{'kernels loop' construct is here}}158  for(;;);159 160#pragma acc parallel loop161  // expected-error@+6{{loop variable of loop associated with an OpenACC 'parallel loop' construct must be of integer, pointer, or random-access-iterator type (is 'float')}}162  // expected-note@-2{{'parallel loop' construct is here}}163  // expected-error@+4{{OpenACC 'parallel loop' construct must have a terminating condition}}164  // expected-note@-4{{'parallel loop' construct is here}}165  // expected-error@+2{{OpenACC 'parallel loop' variable must monotonically increase or decrease ('++', '--', or compound assignment)}}166  // expected-note@-6{{'parallel loop' construct is here}}167  for(float f = 0;;);168 169#pragma acc serial loop170  // expected-error@+6{{OpenACC 'serial loop' construct must have initialization clause in canonical form ('var = init' or 'T var = init'}}171  // expected-note@-2{{'serial loop' construct is here}}172  // expected-error@+4{{OpenACC 'serial loop' construct must have a terminating condition}}173  // expected-note@-4{{'serial loop' construct is here}}174  // expected-error@+2{{OpenACC 'serial loop' variable must monotonically increase or decrease ('++', '--', or compound assignment)}}175  // expected-note@-6{{'serial loop' construct is here}}176  for(int f;;);177 178#pragma acc kernels loop179  // expected-error@+6{{OpenACC 'kernels loop' construct must have initialization clause in canonical form ('var = init' or 'T var = init'}}180  // expected-note@-2{{'kernels loop' construct is here}}181  // expected-error@+4{{OpenACC 'kernels loop' construct must have a terminating condition}}182  // expected-note@-4{{'kernels loop' construct is here}}183  // expected-error@+2{{OpenACC 'kernels loop' variable must monotonically increase or decrease ('++', '--', or compound assignment)}}184  // expected-note@-6{{'kernels loop' construct is here}}185  for(int f,g;;);186 187#pragma acc parallel loop188  // expected-error@+4{{OpenACC 'parallel loop' construct must have initialization clause in canonical form ('var = init' or 'T var = init'}}189  // expected-note@-2{{'parallel loop' construct is here}}190  // expected-error@+2{{OpenACC 'parallel loop' construct must have a terminating condition}}191  // expected-note@-4{{'parallel loop' construct is here}}192  for(Int f;;++f);193 194#pragma acc serial loop195  // expected-error@+2{{OpenACC 'serial loop' construct must have a terminating condition}}196  // expected-note@-2{{'serial loop' construct is here}}197  for(Int *f = nullptr;;++f);198 199#pragma acc kernels loop200  // expected-error@+2{{OpenACC 'kernels loop' construct must have a terminating condition}}201  // expected-note@-2{{'kernels loop' construct is here}}202  for(IntPtr f = nullptr;;++f);203 204#pragma acc parallel loop205  // expected-error@+2{{OpenACC 'parallel loop' construct must have a terminating condition}}206  // expected-note@-2{{'parallel loop' construct is here}}207  for(Float *f = nullptr;;++f);208 209#pragma acc serial loop210  // expected-error@+6{{loop variable of loop associated with an OpenACC 'serial loop' construct must be of integer, pointer, or random-access-iterator type (is 'SomeStruct')}}211  // expected-note@-2{{'serial loop' construct is here}}212  // expected-error@+4{{OpenACC 'serial loop' construct must have a terminating condition}}213  // expected-note@-4{{'serial loop' construct is here}}214  // expected-error@+2{{OpenACC 'serial loop' variable must monotonically increase or decrease ('++', '--', or compound assignment)}}215  // expected-note@-6{{'serial loop' construct is here}}216  for(SomeStruct f;;);217 218#pragma acc kernels loop219  // expected-error@+4{{loop variable of loop associated with an OpenACC 'kernels loop' construct must be of integer, pointer, or random-access-iterator type (is 'SomeStruct')}}220  // expected-note@-2{{'kernels loop' construct is here}}221  // expected-error@+2{{OpenACC 'kernels loop' construct must have a terminating condition}}222  // expected-note@-4{{'kernels loop' construct is here}}223  for(Struct f;;++f);224 225#pragma acc parallel loop226  // expected-error@+4{{loop variable of loop associated with an OpenACC 'parallel loop' construct must be of integer, pointer, or random-access-iterator type (is 'SomeIterator')}}227  // expected-note@-2{{'parallel loop' construct is here}}228  // expected-error@+2{{OpenACC 'parallel loop' construct must have a terminating condition}}229  // expected-note@-4{{'parallel loop' construct is here}}230  for(SomeIterator f;;++f);231 232#pragma acc serial loop233  // expected-error@+4{{loop variable of loop associated with an OpenACC 'serial loop' construct must be of integer, pointer, or random-access-iterator type (is 'SomeIterator')}}234  // expected-note@-2{{'serial loop' construct is here}}235  // expected-error@+2{{OpenACC 'serial loop' construct must have a terminating condition}}236  // expected-note@-4{{'serial loop' construct is here}}237  for(Iterator f;;++f);238 239#pragma acc kernels loop240  // expected-error@+2{{OpenACC 'kernels loop' construct must have a terminating condition}}241  // expected-note@-2{{'kernels loop' construct is here}}242  for(SomeRAIterator f;;++f);243 244#pragma acc parallel loop245  // expected-error@+2{{OpenACC 'parallel loop' construct must have a terminating condition}}246  // expected-note@-2{{'parallel loop' construct is here}}247  for(RandAccessIterator f;;++f);248 249  Int i;250#pragma acc serial loop251  // expected-error@+4{{OpenACC 'serial loop' construct must have a terminating condition}}252  // expected-note@-2{{'serial loop' construct is here}}253  // expected-error@+2{{OpenACC 'serial loop' variable must monotonically increase or decrease ('++', '--', or compound assignment)}}254  // expected-note@-4{{'serial loop' construct is here}}255  for( i = 0;;);256 257#pragma acc kernels loop258  // expected-error@+6{{OpenACC 'kernels loop' construct must have initialization clause in canonical form ('var = init' or 'T var = init'}}259  // expected-note@-2{{'kernels loop' construct is here}}260  // expected-error@+4{{OpenACC 'kernels loop' construct must have a terminating condition}}261  // expected-note@-4{{'kernels loop' construct is here}}262  // expected-error@+2{{OpenACC 'kernels loop' variable must monotonically increase or decrease ('++', '--', or compound assignment)}}263  // expected-note@-6{{'kernels loop' construct is here}}264  for( i;;);265 266#pragma acc parallel loop267  // expected-error@+6{{OpenACC 'parallel loop' construct must have initialization clause in canonical form ('var = init' or 'T var = init'}}268  // expected-note@-2{{'parallel loop' construct is here}}269  // expected-error@+4{{OpenACC 'parallel loop' construct must have a terminating condition}}270  // expected-note@-4{{'parallel loop' construct is here}}271  // expected-error@+2{{OpenACC 'parallel loop' variable must monotonically increase or decrease ('++', '--', or compound assignment)}}272  // expected-note@-6{{'parallel loop' construct is here}}273  for( int j ;;);274 275#pragma acc serial loop276  // expected-error@+6{{OpenACC 'serial loop' construct must have initialization clause in canonical form ('var = init' or 'T var = init'}}277  // expected-note@-2{{'serial loop' construct is here}}278  // expected-error@+4{{OpenACC 'serial loop' construct must have a terminating condition}}279  // expected-note@-4{{'serial loop' construct is here}}280  // expected-error@+2{{OpenACC 'serial loop' variable must monotonically increase or decrease ('++', '--', or compound assignment)}}281  // expected-note@-6{{'serial loop' construct is here}}282  for( int j, k = 0;;);283 284#pragma acc kernels loop285  // expected-error@+6{{OpenACC 'kernels loop' construct must have initialization clause in canonical form ('var = init' or 'T var = init'}}286  // expected-note@-2{{'kernels loop' construct is here}}287  // expected-error@+4{{OpenACC 'kernels loop' construct must have a terminating condition}}288  // expected-note@-4{{'kernels loop' construct is here}}289  // expected-error@+2{{OpenACC 'kernels loop' variable must monotonically increase or decrease ('++', '--', or compound assignment)}}290  // expected-note@-6{{'kernels loop' construct is here}}291  for(Int f;;);292 293#pragma acc parallel loop294  // expected-error@+4{{OpenACC 'parallel loop' construct must have initialization clause in canonical form ('var = init' or 'T var = init'}}295  // expected-note@-2{{'parallel loop' construct is here}}296  // expected-error@+2{{OpenACC 'parallel loop' construct must have a terminating condition}}297  // expected-note@-4{{'parallel loop' construct is here}}298  for(Int f;;++f);299 300#pragma acc serial loop301  // expected-error@+4{{OpenACC 'serial loop' construct must have initialization clause in canonical form ('var = init' or 'T var = init'}}302  // expected-note@-2{{'serial loop' construct is here}}303  // expected-error@+2{{OpenACC 'serial loop' construct must have a terminating condition}}304  // expected-note@-4{{'serial loop' construct is here}}305  for(Int f;;f+=1);306 307#pragma acc kernels loop308  // expected-error@+6{{OpenACC 'kernels loop' construct must have initialization clause in canonical form ('var = init' or 'T var = init'}}309  // expected-note@-2{{'kernels loop' construct is here}}310  // expected-error@+4{{OpenACC 'kernels loop' construct must have a terminating condition}}311  // expected-note@-4{{'kernels loop' construct is here}}312  // expected-error@+2{{OpenACC 'kernels loop' variable must monotonically increase or decrease ('++', '--', or compound assignment)}}313  // expected-note@-6{{'kernels loop' construct is here}}314  for(Int f;;i+=1);315 316#pragma acc parallel loop317  // expected-error@+6{{OpenACC 'parallel loop' construct must have initialization clause in canonical form ('var = init' or 'T var = init'}}318  // expected-note@-2{{'parallel loop' construct is here}}319  // expected-error@+4{{OpenACC 'parallel loop' construct must have a terminating condition}}320  // expected-note@-4{{'parallel loop' construct is here}}321  // expected-error@+2{{OpenACC 'parallel loop' variable must monotonically increase or decrease ('++', '--', or compound assignment)}}322  // expected-note@-6{{'parallel loop' construct is here}}323  for(Int f;;i++);324 325#pragma acc serial loop326  // expected-error@+4{{OpenACC 'serial loop' construct must have a terminating condition}}327  // expected-note@-2{{'serial loop' construct is here}}328  // expected-error@+2{{OpenACC 'serial loop' variable must monotonically increase or decrease ('++', '--', or compound assignment)}}329  // expected-note@-4{{'serial loop' construct is here}}330  for(RandAccessIterator f;;i++);331 332#pragma acc kernels loop333  // expected-error@+4{{OpenACC 'kernels loop' construct must have a terminating condition}}334  // expected-note@-2{{'kernels loop' construct is here}}335  // expected-error@+2{{OpenACC 'kernels loop' variable must monotonically increase or decrease ('++', '--', or compound assignment)}}336  // expected-note@-4{{'kernels loop' construct is here}}337  for(RandAccessIterator f;;func_call());338 339  // Not much we can do here other than check for random access iterator.340  Int Array[5];341#pragma acc parallel loop342  for(auto X : Array);343 344#pragma acc kernels loop345  // expected-error@+2{{loop variable of loop associated with an OpenACC 'kernels loop' construct must be of integer, pointer, or random-access-iterator type (is 'SomeIterator')}}346  // expected-note@-2{{'kernels loop' construct is here}}347  for(auto X : HasIteratorCollection{});348 349#pragma acc serial loop350  for(auto X : HasRAIteratorCollection{});351 352  RandAccessIterator end;353#pragma acc parallel loop354  for(RandAccessIterator f = 0; f != end; ++f);355 356  RandAccessIterator f;357#pragma acc serial loop358  // expected-error@+2{{OpenACC 'serial loop' construct must have initialization clause in canonical form ('var = init' or 'T var = init'}}359  // expected-note@-2{{'serial loop' construct is here}}360  for(f;f != end;f++);361 362#pragma acc kernels loop363  // expected-error@+2{{OpenACC 'kernels loop' construct must have a terminating condition}}364  // expected-note@-2{{'kernels loop' construct is here}}365  for(f = 0;;++f);366 367#pragma acc parallel loop368  // expected-error@+2{{OpenACC 'parallel loop' construct must have a terminating condition}}369  // expected-note@-2{{'parallel loop' construct is here}}370  for(f = 0;;f++);371 372#pragma acc serial loop373  // expected-error@+2{{OpenACC 'serial loop' construct must have a terminating condition}}374  // expected-note@-2{{'serial loop' construct is here}}375  for(f = 0;;f+=1);376 377#pragma acc kernels loop378  for(f = 0;f != end;++f);379 380#pragma acc parallel loop381  for(f = 0;f != end;f++);382 383#pragma acc parallel loop384  for(f = 0;f != end;f+=1);385}386 387void inst() {388  SeqLoopRules<int, int*, float, SomeStruct, SomeIterator, SomeRAIterator>();389  // expected-note@+1{{in instantiation of function template specialization}}390  LoopRules<int, int*, float, SomeStruct, SomeIterator, SomeRAIterator>();391}392 393