diff options
author | erichkeane <ekeane@nvidia.com> | 2025-04-28 14:05:05 -0700 |
---|---|---|
committer | erichkeane <ekeane@nvidia.com> | 2025-04-28 15:22:47 -0700 |
commit | fec003a18a8b5b3dc56c8b59e3516fafaeda7072 (patch) | |
tree | a77c1967aad3f38edc7c594b71bc6e22a07c6f22 /clang/test/SemaOpenACC/loop-construct.cpp | |
parent | b111da97e81f32fe0fb89f8daa2e7516909a8797 (diff) | |
download | llvm-fec003a18a8b5b3dc56c8b59e3516fafaeda7072.zip llvm-fec003a18a8b5b3dc56c8b59e3516fafaeda7072.tar.gz llvm-fec003a18a8b5b3dc56c8b59e3516fafaeda7072.tar.bz2 |
[OpenACC]Reimplement 'for' loop checks for a loop construct
The 'loop' construct has some pretty strict checks as to what the for
loop associated with it has to look like. The previous implementation
was a little convoluted and missed implementing the 'condition'
checking. Additionally, it did a bad job double-diagnosing with
templates.
This patch rewrites it in a way that does a much better job with the
double-diagnosing, and proeprly implements some checks for the
'condition' of the for loop.
Diffstat (limited to 'clang/test/SemaOpenACC/loop-construct.cpp')
-rw-r--r-- | clang/test/SemaOpenACC/loop-construct.cpp | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/clang/test/SemaOpenACC/loop-construct.cpp b/clang/test/SemaOpenACC/loop-construct.cpp index 5616cac..7509811 100644 --- a/clang/test/SemaOpenACC/loop-construct.cpp +++ b/clang/test/SemaOpenACC/loop-construct.cpp @@ -167,8 +167,8 @@ void LoopRules() { for(int f;;); #pragma acc loop - // expected-error@+6 2{{OpenACC 'loop' construct must have initialization clause in canonical form ('var = init' or 'T var = init'}} - // expected-note@-2 2{{'loop' construct is here}} + // expected-error@+6{{OpenACC 'loop' construct must have initialization clause in canonical form ('var = init' or 'T var = init'}} + // expected-note@-2{{'loop' construct is here}} // expected-error@+4{{OpenACC 'loop' construct must have a terminating condition}} // expected-note@-4{{'loop' construct is here}} // expected-error@+2{{OpenACC 'loop' variable must monotonically increase or decrease ('++', '--', or compound assignment)}} @@ -246,8 +246,8 @@ void LoopRules() { for( i = 0;;); #pragma acc loop - // expected-error@+6 2{{OpenACC 'loop' construct must have initialization clause in canonical form ('var = init' or 'T var = init'}} - // expected-note@-2 2{{'loop' construct is here}} + // expected-error@+6{{OpenACC 'loop' construct must have initialization clause in canonical form ('var = init' or 'T var = init'}} + // expected-note@-2{{'loop' construct is here}} // expected-error@+4{{OpenACC 'loop' construct must have a terminating condition}} // expected-note@-4{{'loop' construct is here}} // expected-error@+2{{OpenACC 'loop' variable must monotonically increase or decrease ('++', '--', or compound assignment)}} @@ -264,8 +264,8 @@ void LoopRules() { for( int j ;;); #pragma acc loop - // expected-error@+6 2{{OpenACC 'loop' construct must have initialization clause in canonical form ('var = init' or 'T var = init'}} - // expected-note@-2 2{{'loop' construct is here}} + // expected-error@+6{{OpenACC 'loop' construct must have initialization clause in canonical form ('var = init' or 'T var = init'}} + // expected-note@-2{{'loop' construct is here}} // expected-error@+4{{OpenACC 'loop' construct must have a terminating condition}} // expected-note@-4{{'loop' construct is here}} // expected-error@+2{{OpenACC 'loop' variable must monotonically increase or decrease ('++', '--', or compound assignment)}} @@ -333,8 +333,8 @@ void LoopRules() { for(auto X : Array); #pragma acc loop - // expected-error@+2 2{{loop variable of loop associated with an OpenACC 'loop' construct must be of integer, pointer, or random-access-iterator type (is 'SomeIterator')}} - // expected-note@-2 2{{'loop' construct is here}} + // expected-error@+2{{loop variable of loop associated with an OpenACC 'loop' construct must be of integer, pointer, or random-access-iterator type (is 'SomeIterator')}} + // expected-note@-2{{'loop' construct is here}} for(auto X : HasIteratorCollection{}); #pragma acc loop @@ -346,8 +346,8 @@ void LoopRules() { RandAccessIterator f; #pragma acc loop - // expected-error@+2 2{{OpenACC 'loop' construct must have initialization clause in canonical form ('var = init' or 'T var = init'}} - // expected-note@-2 2{{'loop' construct is here}} + // expected-error@+2{{OpenACC 'loop' construct must have initialization clause in canonical form ('var = init' or 'T var = init'}} + // expected-note@-2{{'loop' construct is here}} for(f;f != end;f++); #pragma acc loop @@ -373,6 +373,25 @@ void LoopRules() { #pragma acc loop for(f = 0;f != end;f+=1); + +#pragma acc loop + for (int i = 0; 5 >= i; ++i); + + int otherI; + // expected-error@+3{{OpenACC 'loop' construct must have a terminating condition}} + // expected-note@+1{{'loop' construct is here}} +#pragma acc loop + for (int i = 0; otherI != 5; ++i); + + // expected-error@+3{{OpenACC 'loop' construct must have a terminating condition}} + // expected-note@+1{{'loop' construct is here}} +#pragma acc loop + for (int i = 0; i != 5 && i < 3; ++i); + + // expected-error@+3{{OpenACC 'loop' variable must monotonically increase or decrease}} + // expected-note@+1{{'loop' construct is here}} +#pragma acc loop + for (int i = 0; i != 5; ++f); } void inst() { |