Skip to content

Commit bea389e

Browse files
committed
[clang] [CUDA] Support calling consteval function between different target.
1 parent e52ad49 commit bea389e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

clang/lib/Sema/SemaCUDA.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ CUDAFunctionTarget SemaCUDA::IdentifyTarget(const FunctionDecl *D,
143143
if (D->hasAttr<CUDAGlobalAttr>())
144144
return CUDAFunctionTarget::Global;
145145

146+
if (D->isConsteval())
147+
return CUDAFunctionTarget::HostDevice;
148+
146149
if (hasAttr<CUDADeviceAttr>(D, IgnoreImplicitHDAttr)) {
147150
if (hasAttr<CUDAHostAttr>(D, IgnoreImplicitHDAttr))
148151
return CUDAFunctionTarget::HostDevice;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
2+
3+
// expected-no-diagnostics
4+
5+
#include "Inputs/cuda.h"
6+
7+
__device__ consteval int f() { return 0; }
8+
int main() { return f(); }

0 commit comments

Comments
 (0)