Files
RedBear-OS/local/recipes/dev/libclc/source/clang/test/SemaOpenACC/combined-construct-reduction-clause.cpp
T
vasilito cb424d7448 build: static patch-sanity linter (shift-left the malformed-patch class)
verify-patch-sanity.py validates every active recipe .patch has internally-
consistent hunk line counts — catching the 'malformed patch at line N' failure
at commit/CI/preflight time instead of hours into a cook. This cycle hit that
class three times (qtwaylandscanner, sddm, xwayland), each only discovered when
cookbook tried to apply the patch.

Running it across the repo found 29 latent malformed patches (validated against
GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22').
They were harmless only because they sit in vendored recipes (baked, not re-
applied) — but would fail on any version-bump re-derivation. --fix recounts the
hunk headers (body untouched) and repaired all 29.

Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test
(test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats
(empty placeholders, bare-@@ git hunks).
2026-08-01 05:13:02 +03:00

170 lines
7.6 KiB
C++

// RUN: %clang_cc1 %s -fopenacc -verify
struct CompositeOfScalars {
int I;
float F;
short J;
char C;
double D;
_Complex float CF;
_Complex double CD;
};
struct CompositeHasComposite {
int I;
float F;
short J;
char C;
double D;
_Complex float CF;
_Complex double CD;
struct CompositeOfScalars COS; // #COS_FIELD
};
// All of the type checking is done for compute and loop constructs, so only check the basics + the parts that are combined specific.
void uses(unsigned Parm) {
struct CompositeOfScalars CoS;
struct CompositeHasComposite ChC;
int I;
float F;
int Array[5];
// legal on all 3 kinds of combined constructs
#pragma acc parallel loop reduction(+:Parm)
for(int i = 0; i < 5; ++i);
#pragma acc serial loop reduction(&: CoS, I, F)
for(int i = 0; i < 5; ++i);
#pragma acc kernels loop reduction(min: CoS, Array[I], Array[0:I])
for(int i = 0; i < 5; ++i);
// expected-error@+2{{OpenACC 'reduction' composite variable must not have non-scalar field}}
// expected-note@#COS_FIELD{{invalid field is here}}
#pragma acc parallel loop reduction(&: ChC)
for(int i = 0; i < 5; ++i);
#pragma acc kernels loop reduction(+:Parm) num_gangs(I)
for(int i = 0; i < 5; ++i);
// expected-error@+2{{OpenACC 'num_gangs' clause with more than 1 argument may not appear on a 'parallel loop' construct with a 'reduction' clause}}
// expected-note@+1{{previous 'reduction' clause is here}}
#pragma acc parallel loop reduction(+:Parm) num_gangs(I, I)
for(int i = 0; i < 5; ++i);
#pragma acc kernels loop num_gangs(I) reduction(+:Parm)
for(int i = 0; i < 5; ++i);
// expected-error@+2{{OpenACC 'reduction' clause may not appear on a 'parallel loop' construct with a 'num_gangs' clause with more than 1 argument}}
// expected-note@+1{{previous 'num_gangs' clause is here}}
#pragma acc parallel loop num_gangs(I, I) reduction(+:Parm)
for(int i = 0; i < 5; ++i);
// Reduction cannot appear on a loop with a 'gang' of dim>1.
#pragma acc parallel loop gang(dim:1) reduction(+:Parm)
for(int i = 0; i < 5; ++i);
// expected-error@+2{{OpenACC 'reduction' clause cannot appear on the same 'parallel loop' construct as a 'gang' clause with a 'dim' value greater than 1}}
// expected-note@+1{{previous 'gang' clause is here}}
#pragma acc parallel loop gang(dim:2) reduction(+:Parm)
for(int i = 0; i < 5; ++i);
#pragma acc parallel loop reduction(+:Parm) gang(dim:1)
for(int i = 0; i < 5; ++i);
// expected-error@+2{{OpenACC 'gang' clause with a 'dim' value greater than 1 cannot appear on the same 'parallel loop' construct as a 'reduction' clause}}
// expected-note@+1{{previous 'reduction' clause is here}}
#pragma acc parallel loop reduction(+:Parm) gang(dim:2)
for(int i = 0; i < 5; ++i);
// Reduction cannot appear on a loop with a gang and a num_gangs with >1
// explicit argument.
#pragma acc kernels loop num_gangs(I) reduction(+:Parm) gang
for(int i = 0; i < 5; ++i);
#pragma acc kernels loop num_gangs(I) gang reduction(+:Parm)
for(int i = 0; i < 5; ++i);
#pragma acc kernels loop reduction(+:Parm) num_gangs(I) gang
for(int i = 0; i < 5; ++i);
#pragma acc kernels loop reduction(+:Parm) gang num_gangs(I)
for(int i = 0; i < 5; ++i);
#pragma acc kernels loop gang num_gangs(I) reduction(+:Parm)
for(int i = 0; i < 5; ++i);
#pragma acc kernels loop gang reduction(+:Parm) num_gangs(I)
for(int i = 0; i < 5; ++i);
// expected-error@+2{{OpenACC 'reduction' clause may not appear on a 'parallel loop' construct with a 'num_gangs' clause with more than 1 argument}}
// expected-note@+1{{previous 'num_gangs' clause is here}}
#pragma acc parallel loop num_gangs(I, I) reduction(+:Parm) gang
for(int i = 0; i < 5; ++i);
// expected-error@+3{{OpenACC 'reduction' clause cannot appear on the same 'parallel loop' construct as a 'gang' clause and a 'num_gangs' clause with more than one argument}}
// expected-note@+2{{previous 'num_gangs' clause is here}}
// expected-note@+1{{previous 'gang' clause is here}}
#pragma acc parallel loop num_gangs(I, I) gang reduction(+:Parm)
for(int i = 0; i < 5; ++i);
// expected-error@+2{{OpenACC 'num_gangs' clause with more than 1 argument may not appear on a 'parallel loop' construct with a 'reduction' clause}}
// expected-note@+1{{previous 'reduction' clause is here}}
#pragma acc parallel loop reduction(+:Parm) num_gangs(I, I) gang
for(int i = 0; i < 5; ++i);
// expected-error@+3{{OpenACC 'reduction' clause cannot appear on the same 'parallel loop' construct as a 'gang' clause and a 'num_gangs' clause with more than one argument}}
// expected-note@+2{{previous 'reduction' clause is here}}
// expected-note@+1{{previous 'gang' clause is here}}
#pragma acc parallel loop reduction(+:Parm) gang num_gangs(I, I)
for(int i = 0; i < 5; ++i);
// expected-error@+3{{OpenACC 'reduction' clause cannot appear on the same 'parallel loop' construct as a 'gang' clause and a 'num_gangs' clause with more than one argument}}
// expected-note@+2{{previous 'gang' clause is here}}
// expected-note@+1{{previous 'num_gangs' clause is here}}
#pragma acc parallel loop gang num_gangs(I, I) reduction(+:Parm)
for(int i = 0; i < 5; ++i);
// expected-error@+3{{OpenACC 'reduction' clause cannot appear on the same 'parallel loop' construct as a 'gang' clause and a 'num_gangs' clause with more than one argument}}
// expected-note@+2{{previous 'reduction' clause is here}}
// expected-note@+1{{previous 'gang' clause is here}}
#pragma acc parallel loop gang reduction(+:Parm) num_gangs(I, I)
for(int i = 0; i < 5; ++i);
#pragma acc parallel loop num_gangs(I) reduction(+:Parm) gang
for(int i = 0; i < 5; ++i);
#pragma acc parallel loop num_gangs(I) gang reduction(+:Parm)
for(int i = 0; i < 5; ++i);
#pragma acc parallel loop reduction(+:Parm) num_gangs(I) gang
for(int i = 0; i < 5; ++i);
#pragma acc parallel loop reduction(+:Parm) gang num_gangs(I)
for(int i = 0; i < 5; ++i);
#pragma acc parallel loop gang num_gangs(I) reduction(+:Parm)
for(int i = 0; i < 5; ++i);
#pragma acc parallel loop gang reduction(+:Parm) num_gangs(I)
for(int i = 0; i < 5; ++i);
#pragma acc parallel loop reduction(+:I)
for(int i = 0; i < 5; ++i) {
// expected-error@+2{{OpenACC 'reduction' variable must have the same operator in all nested constructs (& vs +)}}
// expected-note@-3{{previous 'reduction' clause is here}}
#pragma acc loop reduction(&:I)
for(int i = 0; i < 5; ++i);
}
#pragma acc parallel loop reduction(+:I)
for(int i = 0; i < 5; ++i) {
// expected-error@+2{{OpenACC 'reduction' variable must have the same operator in all nested constructs (& vs +)}}
// expected-note@-3{{previous 'reduction' clause is here}}
#pragma acc parallel reduction(&:I)
for(int i = 0; i < 5; ++i);
}
#pragma acc parallel loop reduction(+:I)
for(int i = 0; i < 5; ++i) {
// expected-error@+2{{OpenACC 'reduction' variable must have the same operator in all nested constructs (& vs +)}}
// expected-note@-3{{previous 'reduction' clause is here}}
#pragma acc parallel loop reduction(&:I)
for(int i = 0; i < 5; ++i);
}
#pragma acc loop reduction(+:I)
for(int i = 0; i < 5; ++i) {
// expected-error@+2{{OpenACC 'reduction' variable must have the same operator in all nested constructs (& vs +)}}
// expected-note@-3{{previous 'reduction' clause is here}}
#pragma acc parallel loop reduction(&:I)
for(int i = 0; i < 5; ++i);
}
#pragma acc parallel reduction(+:I)
for(int i = 0; i < 5; ++i) {
// expected-error@+2{{OpenACC 'reduction' variable must have the same operator in all nested constructs (& vs +)}}
// expected-note@-3{{previous 'reduction' clause is here}}
#pragma acc parallel loop reduction(&:I)
for(int i = 0; i < 5; ++i);
}
}