[clang] [clang][bytecode] Reject erroneous vector conversions (PR #201368)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 3 07:23:28 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/201368.diff
2 Files Affected:
- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+3)
- (modified) clang/test/AST/ByteCode/cxx23.cpp (+14)
``````````diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 732a9e227430c..88ed24b070bde 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -4388,6 +4388,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
``````````
</details>
https://github.com/llvm/llvm-project/pull/201368
More information about the cfe-commits
mailing list