[clang] 1960c7a - [clang][bytecode] Reject erroneous vector conversions (#201368)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 4 02:00:59 PDT 2026
Author: Timm Baeder
Date: 2026-06-04T11:00:54+02:00
New Revision: 1960c7a9fdf2fc613a148fbc078173adddd6ca13
URL: https://github.com/llvm/llvm-project/commit/1960c7a9fdf2fc613a148fbc078173adddd6ca13
DIFF: https://github.com/llvm/llvm-project/commit/1960c7a9fdf2fc613a148fbc078173adddd6ca13.diff
LOG: [clang][bytecode] Reject erroneous vector conversions (#201368)
Added:
Modified:
clang/lib/AST/ByteCode/Compiler.cpp
clang/test/AST/ByteCode/cxx23.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 4d6abee270143..4784627bca3b9 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -4390,6 +4390,9 @@ bool Compiler<Emitter>::VisitAddrLabelExpr(const AddrLabelExpr *E) {
template <class Emitter>
bool Compiler<Emitter>::emitVectorConversion(const Expr *Src, const Expr *E) {
+ if (Src->containsErrors())
+ return false;
+
const auto *VT = E->getType()->castAs<VectorType>();
QualType ElemType = VT->getElementType();
PrimType ElemT = classifyPrim(ElemType);
diff --git a/clang/test/AST/ByteCode/cxx23.cpp b/clang/test/AST/ByteCode/cxx23.cpp
index 4619023af83e6..0050d34a47269 100644
--- a/clang/test/AST/ByteCode/cxx23.cpp
+++ b/clang/test/AST/ByteCode/cxx23.cpp
@@ -646,3 +646,17 @@ namespace DynamicCast {
constexpr S s;
constexpr int foo = (dynamic_cast<const S &>(s), 0);
}
+
+#if __cplusplus >= 202302L
+namespace BrokenShuffleVector {
+ typedef float __m128 __attribute__((__vector_size__(16)));
+
+ static inline constexpr __m128 _mm_cvtps_pd(__m128 z) {
+ __builtin_convertvector(__builtin_shufflevector(z, z), __m128); // all-error {{first two arguments to '__builtin_shufflevector' must have the same type}} \
+ // all-warning {{expression result unused}}
+ }
+
+ constexpr __m128 kf1{1.0f, 2.0f, 3.0f, 4.0f};
+ constexpr __m128 v_mm_cvtps_pd = _mm_cvtps_pd(kf1); // all-error {{must be initialized by a constant expression}}
+}
+#endif
More information about the cfe-commits
mailing list