]> granicus.if.org Git - clang/commit
[CUDA] Make unattributed constexpr functions implicitly host+device.
authorJustin Lebar <jlebar@google.com>
Wed, 30 Mar 2016 23:30:21 +0000 (23:30 +0000)
committerJustin Lebar <jlebar@google.com>
Wed, 30 Mar 2016 23:30:21 +0000 (23:30 +0000)
commitfb35fc36e6e57748802fe2d18bd962daaa5bbaa1
tree5857f99942f7d6a30759a75a761e056a49d83d3e
parentc50aacffb4faf784885f896637e34921166beb27
[CUDA] Make unattributed constexpr functions implicitly host+device.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@264964 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Basic/LangOptions.def
include/clang/Driver/CC1Options.td
include/clang/Sema/Sema.h
lib/Frontend/CompilerInvocation.cpp
lib/Sema/SemaCUDA.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaOverload.cpp
test/SemaCUDA/Inputs/overload.h [new file with mode: 0644]
test/SemaCUDA/host-device-constexpr.cu [new file with mode: 0644]
test/SemaCUDA/no-host-device-constexpr.cu [new file with mode: 0644]