[clang] [Clang] [Frontend] fix crash on parsing ternary operator with `vector_size` condition (PR #102004)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 6 14:35:16 PDT 2024
================
@@ -6719,6 +6719,16 @@ QualType Sema::CheckVectorConditionalTypes(ExprResult &Cond, ExprResult &LHS,
: UsualArithmeticConversions(LHS, RHS, QuestionLoc,
ACK_Conditional);
+ if (ResultElementTy.isNull()) {
+ Diag(QuestionLoc, diag::err_conditional_vector_mismatched)
+ << LHSType << RHSType;
+ return {};
+ }
----------------
mizvekov wrote:
So we are checking if we are dealing with the same type just above.
If we don't support different types, then the call to `UsualArithmeticConversions` is useless, so it can be removed and this can be further simplified:
```suggestion
if (!Context.hasSameType(LHSType, RHSType)) {
Diag(QuestionLoc, diag::err_conditional_vector_mismatched)
<< LHSType << RHSType;
return {};
}
QualType ResultElementTy = Context.getCommonSugaredType(LHSType, RHSType);
```
https://github.com/llvm/llvm-project/pull/102004
More information about the cfe-commits
mailing list