Skip to content

Commit 7e6d517

Browse files
Erich Keanebader
authored andcommitted
[SYCL] Fix __has_builtin for __builtin_intel_fpga_reg
__has_builtin reports true on the SYCL Host, even though it is only valid on the SYCL Device. This patch corrects that behavior. Signed-off-by: Erich Keane <[email protected]>
1 parent b42e92e commit 7e6d517

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

clang/lib/Lex/PPMacroExpansion.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,6 +1613,8 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
16131613
// denotes date of behavior change to support calling arbitrary
16141614
// usual allocation and deallocation functions. Required by libc++
16151615
return 201802;
1616+
case Builtin::BI__builtin_intel_fpga_reg:
1617+
return LangOpts.SYCLIsDevice;
16161618
default:
16171619
return true;
16181620
}

clang/test/SemaSYCL/intel-fpga-reg.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ struct st {
1616

1717

1818
#ifdef __SYCL_DEVICE_ONLY__
19+
static_assert(__has_builtin(__builtin_intel_fpga_reg), "");
1920

2021
struct inner {
2122
void (*fp)(); // expected-note {{Field with illegal type declared here}}
@@ -66,6 +67,7 @@ int main() {
6667

6768
#else
6869

70+
static_assert(!__has_builtin(__builtin_intel_fpga_reg), "");
6971
int main() {
7072
A a(3);
7173
A b = __builtin_intel_fpga_reg(a);

0 commit comments

Comments
 (0)