diff options
author | eopXD <yueh.ting.chen@gmail.com> | 2023-02-09 08:12:02 -0800 |
---|---|---|
committer | eopXD <yueh.ting.chen@gmail.com> | 2023-02-13 18:07:00 -0800 |
commit | 235e90c1d760ea38f2af6bf4de2cc9355b89d24c (patch) | |
tree | 7133dee650c6ac07c74e695ba8070656955db391 /clang/lib/Sema/Sema.cpp | |
parent | 4b815d8443db4d041625f022cd26294080e929e6 (diff) | |
download | llvm-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.cpp | 6 |
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; |