[clang][CUDA] Disable float128 diagnostics for device compilation (#83918)

This commit is contained in:
Pranav Kant
2024-03-06 16:40:23 -08:00
committed by GitHub
parent 0497c77e9e
commit 318bff6811
3 changed files with 22 additions and 2 deletions

View File

@@ -4877,7 +4877,9 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo &CI,
NewElemTy = Context.getRealTypeForBitwidth(DestWidth, ExplicitType);
if (NewElemTy.isNull()) {
Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
// Only emit diagnostic on host for 128-bit mode attribute
if (!(DestWidth == 128 && getLangOpts().CUDAIsDevice))
Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
return;
}

View File

@@ -1561,7 +1561,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
break;
case DeclSpec::TST_float128:
if (!S.Context.getTargetInfo().hasFloat128Type() &&
!S.getLangOpts().SYCLIsDevice &&
!S.getLangOpts().SYCLIsDevice && !S.getLangOpts().CUDAIsDevice &&
!(S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsTargetDevice))
S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported)
<< "__float128";

View File

@@ -0,0 +1,18 @@
// CPU-side compilation on x86 (no errors expected).
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -aux-triple nvptx64 -x cuda -fsyntax-only -verify=cpu %s
// GPU-side compilation on x86 (no errors expected)
// RUN: %clang_cc1 -triple nvptx64 -aux-triple x86_64-unknown-linux-gnu -fcuda-is-device -x cuda -fsyntax-only -verify=gpu %s
// cpu-no-diagnostics
typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
typedef __float128 _Float128;
// gpu-note@+1 {{'a' defined here}}
__attribute__((device)) __float128 f(__float128 a, float b) {
// gpu-note@+1 {{'c' defined here}}
__float128 c = b + 1.0;
// gpu-error@+2 {{'a' requires 128 bit size '__float128' type support, but target 'nvptx64' does not support it}}
// gpu-error@+1 {{'c' requires 128 bit size '__float128' type support, but target 'nvptx64' does not support it}}
return a + c;
}