xref: /aosp_15_r20/external/clang/test/SemaCUDA/no-host-device-constexpr.cu (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -std=c++11 -fsyntax-only -fno-cuda-host-device-constexpr -verify %s
2*67e74705SXin Li // RUN: %clang_cc1 -std=c++11 -fsyntax-only -fno-cuda-host-device-constexpr -fcuda-is-device -verify %s
3*67e74705SXin Li 
4*67e74705SXin Li #include "Inputs/cuda.h"
5*67e74705SXin Li 
6*67e74705SXin Li // Check that, with -fno-cuda-host-device-constexpr, constexpr functions are
7*67e74705SXin Li // host-only, and __device__ constexpr functions are still device-only.
8*67e74705SXin Li 
f()9*67e74705SXin Li constexpr int f() { return 0; } // expected-note {{not viable}}
g()10*67e74705SXin Li __device__ constexpr int g() { return 0; } // expected-note {{not viable}}
11*67e74705SXin Li 
foo()12*67e74705SXin Li void __device__ foo() {
13*67e74705SXin Li   f(); // expected-error {{no matching function}}
14*67e74705SXin Li   g();
15*67e74705SXin Li }
16*67e74705SXin Li 
foo()17*67e74705SXin Li void __host__ foo() {
18*67e74705SXin Li   f();
19*67e74705SXin Li   g(); // expected-error {{no matching function}}
20*67e74705SXin Li }
21