-
Notifications
You must be signed in to change notification settings - Fork 788
[SYCL] Reject zero length arrays #1153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bader
merged 19 commits into
intel:sycl
from
cperkinsintel:cperkins-sycl-reject-zero-length-arrays
Mar 3, 2020
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
eaa10ea
disallow zero length arrays in SYCL kernels
cperkinsintel e9dd04a
changing diagnostic code per feedback
cperkinsintel 765d43b
remove braces, per PR request
cperkinsintel fb3d2ac
adding test of deferred diagnostics, per PR request
cperkinsintel 9618333
improved deferred diagnostic testing
cperkinsintel cc9aa9f
Update clang/test/SemaSYCL/deferred-diagnostics-emit.cpp
cperkinsintel 8d92c4d
switched to common fake SYCL scaffolding
cperkinsintel 17a2f44
Update clang/lib/Sema/SemaType.cpp
cperkinsintel b8a67d3
changing comment formatting per PR feedback
cperkinsintel e28c09e
Update clang/test/SemaSYCL/deferred-diagnostics-emit.cpp
cperkinsintel 8634c6e
Update clang/test/SemaSYCL/deferred-diagnostics-emit.cpp
cperkinsintel 0a208a1
updating test. Having problem with 'note' expectation.
cperkinsintel b515e70
Merge branch 'cperkins-sycl-reject-zero-length-arrays' of https://git…
cperkinsintel a1c2eb3
llvm-lit test passing
cperkinsintel 11b2e94
clang-format
cperkinsintel 7d7a2ec
quick comm
cperkinsintel 77a5c88
cf trouble
cperkinsintel f63f410
comment
cperkinsintel dd87de2
lightening test
cperkinsintel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// RUN: %clang_cc1 -fsycl -triple spir64 -fsycl-is-device -verify -fsyntax-only %s | ||
// | ||
// Ensure that the SYCL diagnostics that are typically deferred are correctly emitted. | ||
|
||
// testing that the deferred diagnostics work in conjunction with the SYCL namespaces. | ||
inline namespace cl { | ||
namespace sycl { | ||
|
||
template <typename name, typename Func> | ||
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) { | ||
// expected-note@+1 2{{called by 'kernel_single_task<AName, (lambda}} | ||
kernelFunc(); | ||
} | ||
|
||
} // namespace sycl | ||
} // namespace cl | ||
|
||
//variadic functions from SYCL kernels emit a deferred diagnostic | ||
void variadic(int, ...); | ||
|
||
int calledFromKernel(int a) { | ||
// expected-error@+1 {{zero-length arrays are not permitted in C++}} | ||
int MalArray[0]; | ||
|
||
// expected-error@+1 {{__float128 is not supported on this target}} | ||
__float128 malFloat = 40; | ||
|
||
//expected-error@+1 {{SYCL kernel cannot call a variadic function}} | ||
variadic(5); | ||
|
||
return a + 20; | ||
} | ||
|
||
// template used to specialize a function that contains a lambda that should | ||
// result in a deferred diagnostic being emitted. | ||
// HOWEVER, this is not working presently. | ||
// TODO: re-test after new deferred diagnostic system is merged. | ||
// restore the "FIX!!" tests below | ||
|
||
template <typename T> | ||
void setup_sycl_operation(const T VA[]) { | ||
|
||
cl::sycl::kernel_single_task<class AName>([]() { | ||
// FIX!! xpected-error@+1 {{zero-length arrays are not permitted in C++}} | ||
int OverlookedBadArray[0]; | ||
|
||
// FIX!! xpected-error@+1 {{__float128 is not supported on this target}} | ||
__float128 overlookedBadFloat = 40; | ||
}); | ||
} | ||
|
||
int main(int argc, char **argv) { | ||
|
||
// --- direct lambda testing --- | ||
cl::sycl::kernel_single_task<class AName>([]() { | ||
// expected-error@+1 {{zero-length arrays are not permitted in C++}} | ||
int BadArray[0]; | ||
|
||
// expected-error@+1 {{__float128 is not supported on this target}} | ||
__float128 badFloat = 40; // this SHOULD trigger a diagnostic | ||
|
||
//expected-error@+1 {{SYCL kernel cannot call a variadic function}} | ||
variadic(5); | ||
|
||
// expected-note@+1 {{called by 'operator()'}} | ||
calledFromKernel(10); | ||
}); | ||
|
||
// --- lambda in specialized function testing --- | ||
|
||
//array A is only used to feed the template | ||
const int array_size = 4; | ||
int A[array_size] = {1, 2, 3, 4}; | ||
setup_sycl_operation(A); | ||
|
||
return 0; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.