-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[clang] Only use CheckVectorOperands for fixed-length vector operands #170485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-clang Author: Benjamin Maxwell (MacDue) ChangesFixes #170279 Full diff: https://github.com/llvm/llvm-project/pull/170485.diff 2 Files Affected:
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index cfabd1b76c103..b74f4b00a2d46 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -10363,6 +10363,11 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
QualType LHSType = LHS.get()->getType().getUnqualifiedType();
QualType RHSType = RHS.get()->getType().getUnqualifiedType();
+ // Bail out if either vector is "sizeless". This is only supported in
+ // CheckSizelessVectorOperands.
+ if (LHSType->isSizelessVectorType() || RHSType->isSizelessVectorType())
+ return InvalidOperands(Loc, LHS, RHS);
+
const VectorType *LHSVecType = LHSType->getAs<VectorType>();
const VectorType *RHSVecType = RHSType->getAs<VectorType>();
assert(LHSVecType || RHSVecType);
diff --git a/clang/test/Sema/AArch64/sve-vector-conditional-op.cpp b/clang/test/Sema/AArch64/sve-vector-conditional-op.cpp
index 0ca55e6268658..cda995ece744c 100644
--- a/clang/test/Sema/AArch64/sve-vector-conditional-op.cpp
+++ b/clang/test/Sema/AArch64/sve-vector-conditional-op.cpp
@@ -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')}}
+ 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) {
|
🐧 Linux x64 Test Results
✅ The build succeeded and all tests passed. |
| } | ||
|
|
||
| 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')}} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) 👍
efriedma-quic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes #170279