-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Allow calls through constant expr function pointers #5390
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
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6b2ab43
[SYCL] Allow calls through constant expr function pointers
Fznamznon 6510cab
Merge branch 'sycl' into constexpr-fptr
Fznamznon bf3eaea
Update the test a bit
Fznamznon 1430852
Fix clang-format concerns
Fznamznon 8b968b0
Allow only specified c++ constant expressions
Fznamznon 9f1c64a
Remove unnecessary attribute
Fznamznon 4ae07a0
Add test description
Fznamznon 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,51 @@ | ||
// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify -sycl-std=2020 -std=c++17 %s | ||
|
||
// This test checks that the compiler doesn't emit an error when indirect call | ||
// was made through a function pointer that is constant expression, and makes | ||
// sure that the error is emitted when a function pointer is not a constant | ||
// expression. | ||
|
||
void t() {} | ||
|
||
constexpr auto F = t; | ||
const auto F1 = t; | ||
|
||
typedef void (*SomeFunc)(); | ||
|
||
constexpr SomeFunc foo() { return t; } | ||
|
||
const SomeFunc foo1() { return t; } | ||
|
||
void bar1(const SomeFunc fptr) { | ||
fptr(); | ||
} | ||
|
||
template <auto f> void fooNTTP() { f(); } | ||
|
||
__attribute__((sycl_device)) void bar() { | ||
// OK | ||
constexpr auto f = t; | ||
f(); | ||
const auto f1 = t; | ||
// expected-error@+1 {{SYCL kernel cannot call through a function pointer}} | ||
f1(); | ||
elizabethandrews marked this conversation as resolved.
Show resolved
Hide resolved
|
||
auto f2 = t; | ||
// expected-error@+1 {{SYCL kernel cannot call through a function pointer}} | ||
f2(); | ||
|
||
// OK | ||
F(); | ||
// expected-error@+1 {{SYCL kernel cannot call through a function pointer}} | ||
F1(); | ||
|
||
constexpr auto ff = foo(); | ||
ff(); | ||
const auto ff1 = foo(); | ||
// expected-error@+1 {{SYCL kernel cannot call through a function pointer}} | ||
ff1(); | ||
const auto fff = foo1(); | ||
// expected-error@+1 {{SYCL kernel cannot call through a function pointer}} | ||
fff(); | ||
|
||
fooNTTP<t>(); | ||
} |
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.