mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-16 17:16:42 +00:00

nvcc warns about the following code: `void f(); __device__ void f() {}` but clang does not since clang allows device function to overload host function. Users want clang to emit similar warning to help code to be compatible with nvcc. Since this may cause regression with existing code, the warning is off by default and can be enabled by -Wnvcc-compat. It won't cause warning in system headers, even with -Wnvcc-compat.
20 lines
1.1 KiB
Plaintext
20 lines
1.1 KiB
Plaintext
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only \
|
|
// RUN: -isystem %S/Inputs -verify %s
|
|
// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fsyntax-only \
|
|
// RUN: -isystem %S/Inputs -fcuda-is-device -verify %s
|
|
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only \
|
|
// RUN: -isystem %S/Inputs -verify=redecl -Wnvcc-compat %s
|
|
// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fsyntax-only \
|
|
// RUN: -isystem %S/Inputs -fcuda-is-device -Wnvcc-compat -verify=redecl %s
|
|
|
|
// expected-no-diagnostics
|
|
#include "cuda.h"
|
|
|
|
__device__ void f(); // redecl-note {{previous declaration is here}}
|
|
|
|
void f() {} // redecl-warning {{target-attribute based function overloads are not supported by NVCC and will be treated as a function redeclaration:new declaration is __host__ function, old declaration is __device__ function}}
|
|
|
|
void g(); // redecl-note {{previous declaration is here}}
|
|
|
|
__device__ void g() {} // redecl-warning {{target-attribute based function overloads are not supported by NVCC and will be treated as a function redeclaration:new declaration is __device__ function, old declaration is __host__ function}}
|