Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion clang/lib/Sema/SemaExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5724,12 +5724,14 @@ QualType Sema::CheckVectorConditionalTypes(ExprResult &Cond, ExprResult &LHS,
ResultType = CheckSizelessVectorOperands(LHS, RHS, QuestionLoc,
/*IsCompAssign*/ false,
ArithConvKind::Conditional);
else
else if (LHSType->isVectorType() || RHSType->isVectorType())
ResultType = CheckVectorOperands(
LHS, RHS, QuestionLoc, /*isCompAssign*/ false, /*AllowBothBool*/ true,
/*AllowBoolConversions*/ false,
/*AllowBoolOperation*/ true,
/*ReportInvalid*/ true);
else
return InvalidOperands(QuestionLoc, LHS, RHS);
if (ResultType.isNull())
return {};
} else {
Expand Down
10 changes: 10 additions & 0 deletions clang/test/Sema/AArch64/sve-vector-conditional-op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ auto error_sve_vector_result_matched_element_count(__SVBool_t svbool, __SVUint32
return svbool ? a : b;
}

auto error_fixed_cond_mixed_scalar_and_vector_operands(fixed_vector cond, unsigned char a, __SVUint8_t b) {
// expected-error@+1 {{invalid operands to binary expression ('unsigned char' and '__SVUint8_t')}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These diagnostics are pretty hard to understand.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've not changed the second error (that was already present), but I agree. I'll see if a more appropriate message already exists. If not, I'll add one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reworked both error messages (by extending an existing error) 👍

return cond ? a : b;
}

auto error_scalable_cond_mixed_scalar_and_vector_operands(__SVBool_t svbool, unsigned char a, fixed_vector b) {
// expected-error@+1 {{cannot convert between vector and non-scalar values ('unsigned char' and 'fixed_vector' (vector of 1 'int' value))}}
return svbool ? a : b;
}

// The following cases should be supported:

__SVBool_t cond_svbool(__SVBool_t a, __SVBool_t b) {
Expand Down