Skip to content

Commit 471f8f5

Browse files
authored
[RISCV] Prevent checkRVVTypeSupport from issuing more than 1 diagnostic. (#74950)
If vector isn't enabled at all, we might hit one of the earlier diagnostics and the requires Zve32x diagnostic. The Zve32x diagnostic would be redundant.
1 parent 3e75dec commit 471f8f5

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

clang/lib/Sema/SemaChecking.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6181,22 +6181,22 @@ void Sema::checkRVVTypeSupport(QualType Ty, SourceLocation Loc, Decl *D) {
61816181
if (((EltSize == 64 && Info.ElementType->isIntegerType()) || MinElts == 1) &&
61826182
!TI.hasFeature("zve64x"))
61836183
Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zve64x";
6184-
if (Info.ElementType->isFloat16Type() && !TI.hasFeature("zvfh") &&
6185-
!TI.hasFeature("zvfhmin"))
6184+
else if (Info.ElementType->isFloat16Type() && !TI.hasFeature("zvfh") &&
6185+
!TI.hasFeature("zvfhmin"))
61866186
Diag(Loc, diag::err_riscv_type_requires_extension, D)
61876187
<< Ty << "zvfh or zvfhmin";
6188-
if (Info.ElementType->isBFloat16Type() &&
6189-
!TI.hasFeature("experimental-zvfbfmin"))
6188+
else if (Info.ElementType->isBFloat16Type() &&
6189+
!TI.hasFeature("experimental-zvfbfmin"))
61906190
Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zvfbfmin";
6191-
if (Info.ElementType->isSpecificBuiltinType(BuiltinType::Float) &&
6192-
!TI.hasFeature("zve32f"))
6191+
else if (Info.ElementType->isSpecificBuiltinType(BuiltinType::Float) &&
6192+
!TI.hasFeature("zve32f"))
61936193
Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zve32f";
6194-
if (Info.ElementType->isSpecificBuiltinType(BuiltinType::Double) &&
6195-
!TI.hasFeature("zve64d"))
6194+
else if (Info.ElementType->isSpecificBuiltinType(BuiltinType::Double) &&
6195+
!TI.hasFeature("zve64d"))
61966196
Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zve64d";
61976197
// Given that caller already checked isRVVType() before calling this function,
61986198
// if we don't have at least zve32x supported, then we need to emit error.
6199-
if (!TI.hasFeature("zve32x"))
6199+
else if (!TI.hasFeature("zve32x"))
62006200
Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zve32x";
62016201
}
62026202

0 commit comments

Comments
 (0)