aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/Sema.cpp
diff options
context:
space:
mode:
authoreopXD <yueh.ting.chen@gmail.com>2023-02-09 08:12:02 -0800
committereopXD <yueh.ting.chen@gmail.com>2023-02-13 18:07:00 -0800
commit235e90c1d760ea38f2af6bf4de2cc9355b89d24c (patch)
tree7133dee650c6ac07c74e695ba8070656955db391 /clang/lib/Sema/Sema.cpp
parent4b815d8443db4d041625f022cd26294080e929e6 (diff)
downloadllvm-235e90c1d760ea38f2af6bf4de2cc9355b89d24c.zip
llvm-235e90c1d760ea38f2af6bf4de2cc9355b89d24c.tar.gz
llvm-235e90c1d760ea38f2af6bf4de2cc9355b89d24c.tar.bz2
[Clang][RISCV] Guard vector float16 type correctly with semantic analysis
Before this commit, vector float 16 types (e.g. `vfloat16m1_t`) of RVV is only defined when extension `zvfh` is defined. However this generate inaccurate diagnostics like: ``` error: unknown type name 'vfloat16m1_t' ``` This commit improves the compiler by guarding type check correctly under semantic analysis. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D143657
Diffstat (limited to 'clang/lib/Sema/Sema.cpp')
-rw-r--r--clang/lib/Sema/Sema.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index f983c47..fd41276 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -2039,6 +2039,12 @@ void Sema::checkTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D) {
targetDiag(D->getLocation(), diag::note_defined_here, FD) << D;
}
+ if (Ty->isRVVType(/* Bitwidth */ 16, /* IsFloat */ true) &&
+ !Context.getTargetInfo().hasFeature("experimental-zvfh")) {
+ Diag(Loc, diag::err_riscv_type_requires_extension, FD)
+ << Ty << "zvfh";
+ }
+
// Don't allow SVE types in functions without a SVE target.
if (Ty->isSVESizelessBuiltinType() && FD && FD->hasBody()) {
llvm::StringMap<bool> CallerFeatureMap;