Files
RedBear-OS/local/recipes/dev/libclc/source/clang/test/SemaOpenACC/loop-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

367 lines
11 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
};
void uses() {
int I;
float F;
int Array[5];
CompositeOfScalars CoS;
CompositeHasComposite ChC;
#pragma acc serial
{
#pragma acc loop reduction(+:CoS, I, F)
for(int i = 0; i < 5; ++i){}
}
#pragma acc serial
{
// expected-error@+1{{OpenACC 'reduction' variable must be of scalar type, sub-array, or a composite of scalar types; type is 'int[5]'}}
#pragma acc loop reduction(+:Array)
for(int i = 0; i < 5; ++i){}
}
#pragma acc serial
{
// expected-error@+2{{OpenACC 'reduction' composite variable must not have non-scalar field}}
// expected-note@#COS_FIELD{{invalid field is here}}
#pragma acc loop reduction(+:ChC)
for(int i = 0; i < 5; ++i){}
}
#pragma acc serial
{
#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 loop reduction(&:I)
for(int i = 0; i < 5; ++i) {
}
}
}
#pragma acc serial
{
#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 loop reduction(&:I)
for(int i = 0; i < 5; ++i) {
}
}
}
#pragma acc serial
{
#pragma acc loop reduction(+:I)
for(int i = 0; i < 5; ++i) {
#pragma acc serial
// expected-error@+2{{OpenACC 'reduction' variable must have the same operator in all nested constructs (& vs +)}}
// expected-note@-4{{previous 'reduction' clause is here}}
#pragma acc loop reduction(&:I)
for(int i = 0; i < 5; ++i) {
}
}
}
#pragma acc serial reduction(+:I)
// expected-error@+2{{OpenACC 'reduction' variable must have the same operator in all nested constructs (& vs +)}}
// expected-note@-2{{previous 'reduction' clause is here}}
#pragma acc loop reduction(&:I)
for(int i = 0; i < 5; ++i){}
#pragma acc serial
#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 serial reduction(+:I)
;
}
#pragma acc parallel
{
#pragma acc loop reduction(+:I) gang(dim:1)
for(int i = 0; i < 5; ++i) {
}
}
#pragma acc parallel
{
// expected-error@+2{{OpenACC 'gang' clause with a 'dim' value greater than 1 cannot appear on the same 'loop' construct as a 'reduction' clause}}
// expected-note@+1{{previous 'reduction' clause is here}}
#pragma acc loop reduction(+:I) gang(dim:2)
for(int i = 0; i < 5; ++i) {
}
}
#pragma acc parallel
{
// expected-error@+2{{OpenACC 'reduction' clause cannot appear on the same 'loop' construct as a 'gang' clause with a 'dim' value greater than 1}}
// expected-note@+1{{previous 'gang' clause is here}}
#pragma acc loop gang(dim:2) reduction(+:I)
for(int i = 0; i < 5; ++i) {
}
}
#pragma acc parallel
{
// expected-error@+2{{OpenACC 'reduction' clause cannot appear on the same 'loop' construct as a 'gang' clause with a 'dim' value greater than 1}}
// expected-note@+1{{previous 'gang' clause is here}}
#pragma acc loop gang gang(dim:1) gang(dim:2) reduction(+:I)
for(int i = 0; i < 5; ++i) {
}
}
#pragma acc parallel num_gangs(1, 2)
{
// expected-error@+3{{OpenACC 'reduction' clause cannot appear on the same 'loop' construct as a 'gang' clause inside a compute construct with a 'num_gangs' clause with more than one argument}}
// expected-note@+2{{previous 'gang' clause is here}}
// expected-note@-4{{previous 'num_gangs' clause is here}}
#pragma acc loop gang(dim:1) reduction(+:I)
for(int i = 0; i < 5; ++i) {
}
}
#pragma acc parallel num_gangs(2, 3)
{
// expected-error@+3{{OpenACC 'gang' clause cannot appear on the same 'loop' construct as a 'reduction' clause inside a compute construct with a 'num_gangs' clause with more than one argument}}
// expected-note@+2{{previous 'reduction' clause is here}}
// expected-note@-4{{previous 'num_gangs' clause is here}}
#pragma acc loop reduction(+:I) gang(dim:1)
for(int i = 0; i < 5; ++i) {
}
}
}
template<typename IntTy, typename CoSTy, typename ChCTy, unsigned One,
unsigned Two>
void templ_uses() {
IntTy I;
IntTy Array[5];
CoSTy CoS;
ChCTy ChC;
#pragma acc serial
{
#pragma acc loop reduction(+:CoS, I)
for(int i = 0; i < 5; ++i){}
}
#pragma acc serial
{
// expected-error@+1{{OpenACC 'reduction' variable must be of scalar type, sub-array, or a composite of scalar types; type is 'int[5]'}}
#pragma acc loop reduction(+:Array)
for(int i = 0; i < 5; ++i){}
}
#pragma acc serial
{
// expected-error@+2{{OpenACC 'reduction' composite variable must not have non-scalar field}}
// expected-note@#COS_FIELD{{invalid field is here}}
#pragma acc loop reduction(+:ChC)
for(int i = 0; i < 5; ++i){}
}
#pragma acc serial
{
#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 loop reduction(&:I)
for(int i = 0; i < 5; ++i) {
}
}
}
#pragma acc serial
{
#pragma acc loop reduction(+:Array[3])
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(&:Array[3])
for(int i = 0; i < 5; ++i) {
}
}
}
#pragma acc serial
{
#pragma acc loop reduction(+:Array[0:3])
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(&:Array[1:4])
for(int i = 0; i < 5; ++i) {
}
}
}
#pragma acc serial
{
#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 serial reduction(&:I)
for(int i = 0; i < 5; ++i) {
}
}
}
#pragma acc parallel
{
#pragma acc loop reduction(+:I) gang(dim:One)
for(int i = 0; i < 5; ++i) {
}
}
#pragma acc parallel
{
// expected-error@+2{{OpenACC 'gang' clause with a 'dim' value greater than 1 cannot appear on the same 'loop' construct as a 'reduction' clause}}
// expected-note@+1{{previous 'reduction' clause is here}}
#pragma acc loop reduction(+:I) gang(dim:2)
for(int i = 0; i < 5; ++i) {
}
}
#pragma acc parallel
{
// expected-error@+2{{OpenACC 'reduction' clause cannot appear on the same 'loop' construct as a 'gang' clause with a 'dim' value greater than 1}}
// expected-note@+1{{previous 'gang' clause is here}}
#pragma acc loop gang(dim:2) reduction(+:I)
for(int i = 0; i < 5; ++i) {
}
}
#pragma acc parallel
{
// expected-error@+2{{OpenACC 'gang' clause with a 'dim' value greater than 1 cannot appear on the same 'loop' construct as a 'reduction' clause}}
// expected-note@+1{{previous 'reduction' clause is here}}
#pragma acc loop reduction(+:I) gang(dim:Two)
for(int i = 0; i < 5; ++i) {
}
}
#pragma acc parallel
{
// expected-error@+2{{OpenACC 'reduction' clause cannot appear on the same 'loop' construct as a 'gang' clause with a 'dim' value greater than 1}}
// expected-note@+1{{previous 'gang' clause is here}}
#pragma acc loop gang(dim:Two) reduction(+:I)
for(int i = 0; i < 5; ++i) {
}
}
#pragma acc parallel num_gangs(One)
{
#pragma acc loop reduction(+:I) gang(dim:One)
for(int i = 0; i < 5; ++i) {
}
}
#pragma acc parallel num_gangs(Two, 1)
{
// expected-error@+3{{OpenACC 'gang' clause cannot appear on the same 'loop' construct as a 'reduction' clause inside a compute construct with a 'num_gangs' clause with more than one argument}}
// expected-note@+2{{previous 'reduction' clause is here}}
// expected-note@-4{{previous 'num_gangs' clause is here}}
#pragma acc loop reduction(+:I) gang(dim:One)
for(int i = 0; i < 5; ++i) {
}
}
#pragma acc parallel num_gangs(Two, 1)
{
// expected-error@+3{{OpenACC 'reduction' clause cannot appear on the same 'loop' construct as a 'gang' clause inside a compute construct with a 'num_gangs' clause with more than one argument}}
// expected-note@+2{{previous 'gang' clause is here}}
// expected-note@-4{{previous 'num_gangs' clause is here}}
#pragma acc loop gang(dim:One) reduction(+:I)
for(int i = 0; i < 5; ++i) {
}
}
#pragma acc parallel num_gangs(One)
{
#pragma acc loop reduction(+:I) gang(dim:1)
for(int i = 0; i < 5; ++i) {
}
}
#pragma acc parallel num_gangs(Two, 1)
{
// expected-error@+3{{OpenACC 'gang' clause cannot appear on the same 'loop' construct as a 'reduction' clause inside a compute construct with a 'num_gangs' clause with more than one argument}}
// expected-note@+2{{previous 'reduction' clause is here}}
// expected-note@-4{{previous 'num_gangs' clause is here}}
#pragma acc loop reduction(+:I) gang(dim:1)
for(int i = 0; i < 5; ++i) {
}
}
#pragma acc parallel num_gangs(Two, 1)
{
// expected-error@+3{{OpenACC 'reduction' clause cannot appear on the same 'loop' construct as a 'gang' clause inside a compute construct with a 'num_gangs' clause with more than one argument}}
// expected-note@+2{{previous 'gang' clause is here}}
// expected-note@-4{{previous 'num_gangs' clause is here}}
#pragma acc loop gang(dim:1) reduction(+:I)
for(int i = 0; i < 5; ++i) {
}
}
#pragma acc parallel num_gangs(1)
{
#pragma acc loop reduction(+:I) gang(dim:One)
for(int i = 0; i < 5; ++i) {
}
}
#pragma acc parallel num_gangs(2, 1)
{
// expected-error@+3{{OpenACC 'gang' clause cannot appear on the same 'loop' construct as a 'reduction' clause inside a compute construct with a 'num_gangs' clause with more than one argument}}
// expected-note@+2{{previous 'reduction' clause is here}}
// expected-note@-4{{previous 'num_gangs' clause is here}}
#pragma acc loop reduction(+:I) gang(dim:One)
for(int i = 0; i < 5; ++i) {
}
}
#pragma acc parallel num_gangs(2, 1)
{
// expected-error@+3{{OpenACC 'reduction' clause cannot appear on the same 'loop' construct as a 'gang' clause inside a compute construct with a 'num_gangs' clause with more than one argument}}
// expected-note@+2{{previous 'gang' clause is here}}
// expected-note@-4{{previous 'num_gangs' clause is here}}
#pragma acc loop gang(dim:One) reduction(+:I)
for(int i = 0; i < 5; ++i) {
}
}
}
void inst() {
// expected-note@+1{{in instantiation of function template specialization}}
templ_uses<int, CompositeOfScalars, CompositeHasComposite, 1, 2>();
}