-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL] Forbid declaration of non-const static variables inside kernels (
#1141) Signed-off-by: Aleksander Fadeev <aleksander.fadeev@intel.com>
- Loading branch information
Showing
5 changed files
with
59 additions
and
29 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,29 @@ | ||
// RUN: %clang_cc1 -verify -fsyntax-only -fsycl-is-device %s | ||
|
||
void usage() { | ||
// expected-error@+1{{SYCL kernel cannot use a non-const static data variable}} | ||
static int s1; | ||
const static int cs = 0; | ||
constexpr static int ces = 0; | ||
} | ||
|
||
template <typename Name, typename Func> | ||
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) { | ||
// expected-error@+1{{SYCL kernel cannot use a non-const static data variable}} | ||
static int z; | ||
// expected-note-re@+2{{called by 'kernel_single_task<fake_kernel, (lambda at {{.*}})>}} | ||
// expected-note-re@+1{{called by 'kernel_single_task<fake_kernel, (lambda at {{.*}})>}} | ||
kernelFunc(); | ||
} | ||
|
||
int main() { | ||
static int s2; | ||
kernel_single_task<class fake_kernel>([]() { | ||
// expected-note@+1{{called by 'operator()'}} | ||
usage(); | ||
// expected-error@+1{{SYCL kernel cannot use a non-const static data variable}} | ||
static int s3; | ||
}); | ||
|
||
return 0; | ||
} |