-
Notifications
You must be signed in to change notification settings - Fork 768
[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
Changes from 9 commits
eaa10ea
e9dd04a
765d43b
fb3d2ac
9618333
cc9aa9f
8d92c4d
17a2f44
b8a67d3
e28c09e
8634c6e
0a208a1
b515e70
a1c2eb3
11b2e94
7d7a2ec
77a5c88
f63f410
dd87de2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,85 @@ | ||||
// RUN: %clang_cc1 -I %S/Inputs -fcxx-exceptions -triple spir64 -fsycl-is-device -Wno-return-type -verify -fsyntax-only %s | ||||
cperkinsintel marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
|
||||
// | ||||
// ensuring that the SYCL diagnostics that are typically deferred, correctly emit | ||||
cperkinsintel marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
// | ||||
|
||||
#include <sycl.hpp> | ||||
|
||||
struct S { | ||||
virtual void foo() {} | ||||
}; | ||||
|
||||
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; | ||||
|
||||
// not sure if 'no virtual function' is a _deferred_ diagnostic, testing anyway | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What exactly do you mean here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure if this particular violation ( a virtual function in SYCL context ) results in a deferred diagnostic, as opposed to an immediate diagnostic. @erichkeane added it to one of the files when he was working on reducing the problem. So I kept it in the test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIK we diagnose virtual functions usage through SemaSYCL callgraph traversing. See llvm/clang/lib/Sema/SemaSYCL.cpp Line 233 in f87291d
But we already diagnose variadic function calls through deferred diagnostic, I remember patch from Erich doing this #998 . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I switched to variadic. |
||||
S mal; | ||||
// expected-error@+1 {{SYCL kernel cannot call a virtual function}} | ||||
mal.foo(); | ||||
|
||||
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::range<1> numOfItems; | ||||
cl::sycl::queue deviceQueue; | ||||
|
||||
deviceQueue.submit([&](cl::sycl::handler &cgh) { | ||||
cgh.single_task<class AName>([=]() { | ||||
// FIX!! expected-error@+1 {{zero-length arrays are not permitted in C++}} | ||||
int OverlookedBadArray[0]; | ||||
|
||||
// FIX!! expected-error@+1 {{__float128 is not supported on this target}} | ||||
__float128 overlookedBadFloat = 40; | ||||
|
||||
}); | ||||
}); | ||||
} | ||||
|
||||
int main(int argc, char **argv) { | ||||
|
||||
// --- direct lambda testing --- | ||||
cl::sycl::range<1> numOfItems; | ||||
cl::sycl::queue deviceQueue; | ||||
|
||||
deviceQueue.submit([&](cl::sycl::handler &cgh) { | ||||
cgh.single_task<class AName>([=]() { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Fznamznon When running
So it looks like I should add this expectation:
But no matter where I put that expectation it never works. First it tells me it expected the note but didn't see it, then it says it saw the note without expecting it. Awesome.
Is the expectation correct? I haven't been able to find docs for them, so I'm just cribbing from other places. I tried putting the expectation at line 58, line 60, in the argument list of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a compiler flag to suppress the notes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. First, I don't think that we should suppress notes in tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok - I re-introduced the bespoke SYCL namespace code into the test and put the expectation into it. Now the llvm-lit passes and the test correctly stresses the namespace aspect we require. |
||||
// 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 | ||||
|
||||
// not sure if 'no virtual function' is a _deferred_ diagnostic, but testing anyway. | ||||
S s; | ||||
// expected-error@+1 {{SYCL kernel cannot call a virtual function}} | ||||
s.foo(); | ||||
|
||||
calledFromKernel(10); | ||||
}); | ||||
}); | ||||
|
||||
|
||||
// --- lambda in specialized function testing --- | ||||
|
||||
//array A is only used to feed the template | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. The diagnostics do not emit if the lambda that contains the violations appears in a templated function. So I'm just using the array to specialize the template. |
||||
const int array_size = 4; | ||||
int A[array_size] = {1, 2, 3, 4}; | ||||
setup_sycl_operation(A); | ||||
|
||||
return 0; | ||||
} |
Uh oh!
There was an error while loading. Please reload this page.