forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CUDA][HIP] warn incompatible redeclare
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 -Woffload-incompatible-redeclare. It won't cause warning in system headers, even with -Woffload-incompatible-redeclare.
- Loading branch information
Showing
3 changed files
with
46 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// 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 -Woffload-incompatible-redeclare %s | ||
// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fsyntax-only \ | ||
// RUN: -isystem %S/Inputs -fcuda-is-device -Woffload-incompatible-redeclare -verify=redecl %s | ||
|
||
// expected-no-diagnostics | ||
#include "cuda.h" | ||
|
||
__device__ void f(); // redecl-note {{previous declaration is here}} | ||
|
||
void f() {} // redecl-warning {{incompatible host/device attribute with redeclaration: new declaration is __host__ function, old declaration is __device__ function. It will cause warning with nvcc}} | ||
|
||
void g(); // redecl-note {{previous declaration is here}} | ||
|
||
__device__ void g() {} // redecl-warning {{incompatible host/device attribute with redeclaration: new declaration is __device__ function, old declaration is __host__ function. It will cause warning with nvcc}} |