[clang] [clang][CUDA] Disable float128 diagnostics for device compilation (PR #83918)
Pranav Kant via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 4 14:25:04 PST 2024
https://github.com/pranavk created https://github.com/llvm/llvm-project/pull/83918
None
>From 39fa380fc3df9775e59b1957dca4a7f927702360 Mon Sep 17 00:00:00 2001
From: Pranav Kant <prka at google.com>
Date: Mon, 4 Mar 2024 22:19:04 +0000
Subject: [PATCH] [clang][CUDA] Disable float128 diagnostics for device
compilation
---
clang/lib/Sema/SemaDeclAttr.cpp | 4 +++-
clang/lib/Sema/SemaType.cpp | 1 +
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 397b5db0dc0669..e6943efb345ce0 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -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;
}
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 1e43e36016a66f..4a4e6f80d0d049 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1562,6 +1562,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
case DeclSpec::TST_float128:
if (!S.Context.getTargetInfo().hasFloat128Type() &&
!S.getLangOpts().SYCLIsDevice &&
+ !S.getLangOpts().CUDAIsDevice &&
!(S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsTargetDevice))
S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported)
<< "__float128";
More information about the cfe-commits
mailing list