81 lines · cpp
1// RUN: %clang_cc1 %s -verify -fopenacc2//3// expected-error@+1{{OpenACC construct 'loop' cannot be used here; it can only be used in a statement context}}4#pragma acc loop5 6// expected-error@+1{{OpenACC construct 'loop' cannot be used here; it can only be used in a statement context}}7#pragma acc loop8int foo;9 10struct S {11// expected-error@+1{{OpenACC construct 'loop' cannot be used here; it can only be used in a statement context}}12#pragma acc loop13 int i;14 15 void mem_func() {16 // expected-error@+3{{OpenACC 'loop' construct can only be applied to a 'for' loop}}17 // expected-note@+1{{'loop' construct is here}}18#pragma acc loop19 int foo;20 21 // expected-error@+3{{OpenACC 'loop' construct can only be applied to a 'for' loop}}22 // expected-note@+1{{'loop' construct is here}}23#pragma acc loop24 while(0);25 26 // expected-error@+3{{OpenACC 'loop' construct can only be applied to a 'for' loop}}27 // expected-note@+1{{'loop' construct is here}}28#pragma acc loop29 do{}while(0);30 31 // expected-error@+3{{OpenACC 'loop' construct can only be applied to a 'for' loop}}32 // expected-note@+1{{'loop' construct is here}}33#pragma acc loop34 {}35 36#pragma acc loop37 for(int i = 0; i < 6; ++i);38 39 int array[5];40 41#pragma acc loop42 for(auto X : array){}43}44};45 46template<typename T>47void templ_func() {48 // expected-error@+3{{OpenACC 'loop' construct can only be applied to a 'for' loop}}49 // expected-note@+1{{'loop' construct is here}}50#pragma acc loop51 int foo;52 53 // expected-error@+3{{OpenACC 'loop' construct can only be applied to a 'for' loop}}54 // expected-note@+1{{'loop' construct is here}}55#pragma acc loop56 while(T{});57 58 // expected-error@+3{{OpenACC 'loop' construct can only be applied to a 'for' loop}}59 // expected-note@+1{{'loop' construct is here}}60#pragma acc loop61 do{}while(0);62 63 // expected-error@+3{{OpenACC 'loop' construct can only be applied to a 'for' loop}}64 // expected-note@+1{{'loop' construct is here}}65#pragma acc loop66 {}67 68#pragma acc loop69 for(T i = 0; i < 1; ++i);70 71 T array[5];72 73#pragma acc loop74 for(auto X : array){}75}76 77void use() {78 templ_func<int>();79}80 81