llvm-project/clang/test/SemaOpenACC/combined-construct-worker-clause.cpp
erichkeane 8313d2a8db [OpenACC] Fixup previous-clause diagnostics
Brought up in a previous review as a TODO, we could be better about how
we highlight what hte previous clause was, and how to show that the
'device_type' is the one being targetted.  This patch rewords the
diagnostics and updates a massive number of tests.
2025-05-02 09:35:32 -07:00

151 lines
5.6 KiB
C++

// RUN: %clang_cc1 %s -fopenacc -verify
template<unsigned I>
void TemplUses() {
#pragma acc parallel loop worker
for(int i = 0; i < 5; ++i);
// expected-error@+1{{expected expression}}
#pragma acc parallel loop worker()
for(int i = 0; i < 5; ++i);
// expected-error@+1{{'num' argument on 'worker' clause is not permitted on a 'parallel loop' construct}}
#pragma acc parallel loop worker(I)
for(int i = 0; i < 5; ++i);
// expected-error@+1{{'num' argument on 'worker' clause is not permitted on a 'parallel loop' construct}}
#pragma acc parallel loop worker(num:I)
for(int i = 0; i < 5; ++i);
#pragma acc serial loop worker
for(int i = 0; i < 5; ++i);
// expected-error@+1{{expected expression}}
#pragma acc serial loop worker()
for(int i = 0; i < 5; ++i);
// expected-error@+1{{'num' argument on 'worker' clause is not permitted on a 'serial loop' construct}}
#pragma acc serial loop worker(I)
for(int i = 0; i < 5; ++i);
// expected-error@+1{{'num' argument on 'worker' clause is not permitted on a 'serial loop' construct}}
#pragma acc serial loop worker(num:I)
for(int i = 0; i < 5; ++i);
#pragma acc kernels loop worker(I)
for(int i = 0; i < 5; ++i);
#pragma acc kernels loop worker(num:I)
for(int i = 0; i < 5; ++i);
// expected-error@+2{{'num' argument to 'worker' clause not allowed on a 'kernels loop' construct that has a 'num_workers' clause}}
// expected-note@+1{{previous 'num_workers' clause is here}}
#pragma acc kernels loop num_workers(1) worker(num:I)
for(int i = 0; i < 5; ++i);
// expected-error@+2{{'num_workers' clause not allowed on a 'kernels loop' construct that has a 'worker' clause with an argument}}
// expected-note@+1{{previous 'worker' clause is here}}
#pragma acc kernels loop worker(num:I) num_workers(1)
for(int i = 0; i < 5; ++i);
}
void NormalUses() {
TemplUses<4>();
int I;
#pragma acc parallel loop worker
for(int i = 0; i < 5; ++i);
// expected-error@+1{{expected expression}}
#pragma acc parallel loop worker()
for(int i = 0; i < 5; ++i);
// expected-error@+1{{'num' argument on 'worker' clause is not permitted on a 'parallel loop' construct}}
#pragma acc parallel loop worker(I)
for(int i = 0; i < 5; ++i);
// expected-error@+1{{'num' argument on 'worker' clause is not permitted on a 'parallel loop' construct}}
#pragma acc parallel loop worker(num:I)
for(int i = 0; i < 5; ++i);
#pragma acc serial loop worker
for(int i = 0; i < 5; ++i);
// expected-error@+1{{expected expression}}
#pragma acc serial loop worker()
for(int i = 0; i < 5; ++i);
// expected-error@+1{{'num' argument on 'worker' clause is not permitted on a 'serial loop' construct}}
#pragma acc serial loop worker(I)
for(int i = 0; i < 5; ++i);
// expected-error@+1{{'num' argument on 'worker' clause is not permitted on a 'serial loop' construct}}
#pragma acc serial loop worker(num:I)
for(int i = 0; i < 5; ++i);
#pragma acc kernels loop worker(I)
for(int i = 0; i < 5; ++i);
#pragma acc kernels loop worker(num:I)
for(int i = 0; i < 5; ++i);
// expected-error@+2{{'num' argument to 'worker' clause not allowed on a 'kernels loop' construct that has a 'num_workers' clause}}
// expected-note@+1{{previous 'num_workers' clause is here}}
#pragma acc kernels loop num_workers(1) worker(num:I)
for(int i = 0; i < 5; ++i);
// expected-error@+2{{'num_workers' clause not allowed on a 'kernels loop' construct that has a 'worker' clause with an argument}}
// expected-note@+1{{previous 'worker' clause is here}}
#pragma acc kernels loop worker(num:I) num_workers(1)
for(int i = 0; i < 5; ++i);
// OK, kernels loop is a new compute construct
#pragma acc kernels num_workers(1)
for(int i = 0; i < 5; ++i) {
#pragma acc kernels loop worker(num:1)
for(int i = 0; i < 5; ++i);
}
#pragma acc kernels loop num_workers(1)
for(int i = 0; i < 5; ++i) {
#pragma acc kernels loop worker(num:1)
for(int i = 0; i < 5; ++i);
}
#pragma acc kernels loop num_workers(1)
for(int i = 0; i < 5; ++i) {
// expected-error@+2{{'num' argument to 'worker' clause not allowed on a 'loop' construct associated with a 'kernels loop' construct that has a 'num_workers' clause}}
// expected-note@-3{{previous 'num_workers' clause is here}}
#pragma acc loop worker(num:1)
for(int i = 0; i < 5; ++i);
}
#pragma acc parallel loop worker
for(int i = 0; i < 5; ++i) {
// expected-error@+4{{loop with a 'gang' clause may not exist in the region of a 'worker' clause}}
// expected-note@-3{{previous 'worker' clause is here}}
// expected-error@+2{{loop with a 'worker' clause may not exist in the region of a 'worker' clause}}
// expected-note@-5{{previous 'worker' clause is here}}
#pragma acc loop gang, worker, vector
for(int i = 0; i < 5; ++i);
}
#pragma acc kernels loop worker
for(int i = 0; i < 5; ++i) {
// expected-error@+4{{loop with a 'gang' clause may not exist in the region of a 'worker' clause}}
// expected-note@-3{{previous 'worker' clause is here}}
// expected-error@+2{{loop with a 'worker' clause may not exist in the region of a 'worker' clause}}
// expected-note@-5{{previous 'worker' clause is here}}
#pragma acc loop gang, worker, vector
for(int i = 0; i < 5; ++i);
}
#pragma acc serial loop worker
for(int i = 0; i < 5; ++i) {
// expected-error@+4{{loop with a 'gang' clause may not exist in the region of a 'worker' clause}}
// expected-note@-3{{previous 'worker' clause is here}}
// expected-error@+2{{loop with a 'worker' clause may not exist in the region of a 'worker' clause}}
// expected-note@-5{{previous 'worker' clause is here}}
#pragma acc loop gang, worker, vector
for(int i = 0; i < 5; ++i);
}
}