diff options
author | erichkeane <ekeane@nvidia.com> | 2025-07-24 07:49:09 -0700 |
---|---|---|
committer | erichkeane <ekeane@nvidia.com> | 2025-07-24 08:11:28 -0700 |
commit | 3bd34ec924dbba1bde3856fdc31748200ccfd53f (patch) | |
tree | 154487a40aa8a206d28953fce2e6750596f9cbf9 /clang/test | |
parent | 3ebe5d661f7829b2ffe1b422ec7d00d3213c9730 (diff) | |
download | llvm-3bd34ec924dbba1bde3856fdc31748200ccfd53f.zip llvm-3bd34ec924dbba1bde3856fdc31748200ccfd53f.tar.gz llvm-3bd34ec924dbba1bde3856fdc31748200ccfd53f.tar.bz2 |
[OpenACC] Fix checking of sub-expressions in cache
Running an external test suite (UDel) showed that our expression
comparison for the 'cache' rule checking was overly strict in the
presence of irrelevant parens/casts/etc. This patch ensures we skip
them when checking.
This also changes the diagnostic to say 'sub-expression' instead of
variable, which is more correct.
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/SemaOpenACC/atomic-construct.cpp | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/clang/test/SemaOpenACC/atomic-construct.cpp b/clang/test/SemaOpenACC/atomic-construct.cpp index eba2559..10c85c2 100644 --- a/clang/test/SemaOpenACC/atomic-construct.cpp +++ b/clang/test/SemaOpenACC/atomic-construct.cpp @@ -1098,7 +1098,7 @@ void AtomicCaptureTemplateCompound(T LHS, T RHS) { { LHS--; // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}} - // expected-note@+1{{variable on right hand side of assignment('RHS') must match variable used in unary expression('LHS') from the first statement}} + // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used in unary expression('LHS') from the first statement}} LHS = RHS; } @@ -1128,7 +1128,7 @@ void AtomicCaptureTemplateCompound(T LHS, T RHS) { { LHS *= 1; // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}} - // expected-note@+1{{variable on right hand side of assignment('RHS') must match variable used on left hand side of compound assignment('LHS') from the first statement}} + // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used on left hand side of compound assignment('LHS') from the first statement}} LHS = RHS; } #pragma acc atomic capture @@ -1157,7 +1157,7 @@ void AtomicCaptureTemplateCompound(T LHS, T RHS) { { LHS = LHS * 1; // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}} - // expected-note@+1{{variable on right hand side of assignment('RHS') must match variable used on left hand side of assignment('LHS') from the first statement}} + // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used on left hand side of assignment('LHS') from the first statement}} RHS = RHS; } #pragma acc atomic capture @@ -1186,7 +1186,7 @@ void AtomicCaptureTemplateCompound(T LHS, T RHS) { { LHS = LHS | 1; // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}} - // expected-note@+1{{variable on right hand side of assignment('RHS') must match variable used on left hand side of assignment('LHS') from the first statement}} + // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used on left hand side of assignment('LHS') from the first statement}} RHS = RHS; } #pragma acc atomic capture @@ -1255,7 +1255,7 @@ void AtomicCaptureTemplateCompound(T LHS, T RHS) { { LHS = RHS; // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}} - // expected-note@+1{{variable on left hand side of assignment('LHS') must match variable used on right hand side of assignment('RHS') from the first statement}} + // expected-note@+1{{sub-expression on left hand side of assignment('LHS') must match sub-expression used on right hand side of assignment('RHS') from the first statement}} LHS = 1; } @@ -1294,7 +1294,7 @@ void AtomicCaptureTemplateCompound(T LHS, T RHS) { { LHS = RHS; // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}} - // expected-note@+1{{variable in unary expression('LHS') must match variable used on right hand side of assignment('RHS') from the first statement}} + // expected-note@+1{{sub-expression in unary expression('LHS') must match sub-expression used on right hand side of assignment('RHS') from the first statement}} LHS++; } } @@ -1352,7 +1352,7 @@ void AtomicCaptureTemplateCompound2(T LHS, T RHS) { { LHS--; // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}} - // expected-note@+1{{variable on right hand side of assignment('RHS') must match variable used in unary expression('LHS') from the first statement}} + // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used in unary expression('LHS') from the first statement}} LHS = RHS; } @@ -1384,7 +1384,7 @@ void AtomicCaptureTemplateCompound2(T LHS, T RHS) { { LHS *= 1; // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}} - // expected-note@+1{{variable on right hand side of assignment('RHS') must match variable used on left hand side of compound assignment('LHS') from the first statement}} + // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used on left hand side of compound assignment('LHS') from the first statement}} LHS = RHS; } #pragma acc atomic capture @@ -1415,7 +1415,7 @@ void AtomicCaptureTemplateCompound2(T LHS, T RHS) { { LHS = LHS * 1; // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}} - // expected-note@+1{{variable on right hand side of assignment('RHS') must match variable used on left hand side of assignment('LHS') from the first statement}} + // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used on left hand side of assignment('LHS') from the first statement}} RHS = RHS; } #pragma acc atomic capture @@ -1446,7 +1446,7 @@ void AtomicCaptureTemplateCompound2(T LHS, T RHS) { { LHS = LHS | 1; // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}} - // expected-note@+1{{variable on right hand side of assignment('RHS') must match variable used on left hand side of assignment('LHS') from the first statement}} + // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used on left hand side of assignment('LHS') from the first statement}} RHS = RHS; } #pragma acc atomic capture @@ -1523,7 +1523,7 @@ void AtomicCaptureTemplateCompound2(T LHS, T RHS) { { LHS = RHS; // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}} - // expected-note@+1{{variable on left hand side of assignment('LHS') must match variable used on right hand side of assignment('RHS') from the first statement}} + // expected-note@+1{{sub-expression on left hand side of assignment('LHS') must match sub-expression used on right hand side of assignment('RHS') from the first statement}} LHS = 1; } @@ -1570,7 +1570,7 @@ void AtomicCaptureTemplateCompound2(T LHS, T RHS) { { LHS = RHS; // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}} - // expected-note@+1{{variable in unary expression('LHS') must match variable used on right hand side of assignment('RHS') from the first statement}} + // expected-note@+1{{sub-expression in unary expression('LHS') must match sub-expression used on right hand side of assignment('RHS') from the first statement}} LHS++; } } @@ -1629,7 +1629,7 @@ void AtomicCaptureCompound(int LHS, int RHS) { { LHS--; // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}} - // expected-note@+1{{variable on right hand side of assignment('RHS') must match variable used in unary expression('LHS') from the first statement}} + // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used in unary expression('LHS') from the first statement}} LHS = RHS; } @@ -1666,7 +1666,7 @@ void AtomicCaptureCompound(int LHS, int RHS) { { LHS *= 1; // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}} - // expected-note@+1{{variable on right hand side of assignment('RHS') must match variable used on left hand side of compound assignment('LHS') from the first statement}} + // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used on left hand side of compound assignment('LHS') from the first statement}} LHS = RHS; } #pragma acc atomic capture @@ -1702,7 +1702,7 @@ void AtomicCaptureCompound(int LHS, int RHS) { { LHS = LHS * 1; // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}} - // expected-note@+1{{variable on right hand side of assignment('RHS') must match variable used on left hand side of assignment('LHS') from the first statement}} + // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used on left hand side of assignment('LHS') from the first statement}} RHS = RHS; } #pragma acc atomic capture @@ -1738,7 +1738,7 @@ void AtomicCaptureCompound(int LHS, int RHS) { { LHS = LHS | 1; // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}} - // expected-note@+1{{variable on right hand side of assignment('RHS') must match variable used on left hand side of assignment('LHS') from the first statement}} + // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used on left hand side of assignment('LHS') from the first statement}} RHS = RHS; } #pragma acc atomic capture @@ -1815,7 +1815,7 @@ void AtomicCaptureCompound(int LHS, int RHS) { { LHS = RHS; // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}} - // expected-note@+1{{variable on left hand side of assignment('LHS') must match variable used on right hand side of assignment('RHS') from the first statement}} + // expected-note@+1{{sub-expression on left hand side of assignment('LHS') must match sub-expression used on right hand side of assignment('RHS') from the first statement}} LHS = 1; } @@ -1861,7 +1861,23 @@ void AtomicCaptureCompound(int LHS, int RHS) { { LHS = RHS; // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}} - // expected-note@+1{{variable in unary expression('LHS') must match variable used on right hand side of assignment('RHS') from the first statement}} + // expected-note@+1{{sub-expression in unary expression('LHS') must match sub-expression used on right hand side of assignment('RHS') from the first statement}} LHS++; } + + // Example from UDel test suite, which wasn't working because of irrelevant + // parens, make sure we work with these. This should not diagnose. + typedef double real_t; + int * distribution; + real_t *a; + real_t *b; + int *c; + for (int x = 0; x < 5; ++x) { +#pragma acc atomic capture + { + c[x] = distribution[(int) (a[x]*b[x]/10)]; + (distribution[(int)(a[x]*b[x]/10)])--; + } + } + } |