https://github.com/MacDue updated https://github.com/llvm/llvm-project/pull/170485
>From 3e55858c79df00e3e2890279fc9673cd33931f29 Mon Sep 17 00:00:00 2001 From: Benjamin Maxwell <[email protected]> Date: Wed, 3 Dec 2025 14:28:16 +0000 Subject: [PATCH 1/2] [clang] Only use CheckVectorOperands for fixed-length vector operands Fixes #170279 --- clang/lib/Sema/SemaExprCXX.cpp | 4 +++- clang/test/Sema/AArch64/sve-vector-conditional-op.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 69719ebd1fc8c..b5adc52a8450e 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -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() || LHSType->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 { 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) { >From 5a25ee29730105e8593e4df5095de1764a3d0d91 Mon Sep 17 00:00:00 2001 From: Benjamin Maxwell <[email protected]> Date: Wed, 3 Dec 2025 16:29:42 +0000 Subject: [PATCH 2/2] Fix condition check for vector types in SemaExprCXX --- clang/lib/Sema/SemaExprCXX.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index b5adc52a8450e..ae59903ddc00e 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -5724,7 +5724,7 @@ QualType Sema::CheckVectorConditionalTypes(ExprResult &Cond, ExprResult &LHS, ResultType = CheckSizelessVectorOperands(LHS, RHS, QuestionLoc, /*IsCompAssign*/ false, ArithConvKind::Conditional); - else if (LHSType->isVectorType() || LHSType->isVectorType()) + else if (LHSType->isVectorType() || RHSType->isVectorType()) ResultType = CheckVectorOperands( LHS, RHS, QuestionLoc, /*isCompAssign*/ false, /*AllowBothBool*/ true, /*AllowBoolConversions*/ false, _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
