mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-03-04 16:41:43 +00:00

With this patch, by a constexpr function is implicitly host+device unless: a) it's a variadic function (variadic functions are not allowed on the device side), or b) it's preceeded by a __device__ overload in a system header. The restriction on overloading __host__ __device__ functions on the basis of their CUDA attributes remains in place, but we use (b) to allow us to define __device__ overloads for constexpr functions in cmath, which would otherwise be __host__ __device__ and thus not overloadable. You can disable this behavior with -fno-cuda-host-device-constexpr. Reviewers: tra, rnk, rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18380 llvm-svn: 264964
21 lines
673 B
Plaintext
21 lines
673 B
Plaintext
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fno-cuda-host-device-constexpr -verify %s
|
|
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fno-cuda-host-device-constexpr -fcuda-is-device -verify %s
|
|
|
|
#include "Inputs/cuda.h"
|
|
|
|
// Check that, with -fno-cuda-host-device-constexpr, constexpr functions are
|
|
// host-only, and __device__ constexpr functions are still device-only.
|
|
|
|
constexpr int f() { return 0; } // expected-note {{not viable}}
|
|
__device__ constexpr int g() { return 0; } // expected-note {{not viable}}
|
|
|
|
void __device__ foo() {
|
|
f(); // expected-error {{no matching function}}
|
|
g();
|
|
}
|
|
|
|
void __host__ foo() {
|
|
f();
|
|
g(); // expected-error {{no matching function}}
|
|
}
|