[clang] [clang] Reject references to vector types in `__builtin_vectorelements` (PR #219767)

Akash Manna via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 9 07:49:06 PDT 2026


================
@@ -4742,6 +4742,12 @@ bool Sema::CheckUnaryExprOrTypeTraitOperand(QualType ExprType,
   if (ExprType->isDependentType())
     return false;
 
+  // A reference to a vector type is not a vector type; check this before the
+  // reference is looked through below.
+  if (ExprKind == UETT_VectorElements)
+    return CheckVectorElementsTraitOperandType(*this, ExprType, OpLoc,
----------------
akash-manna-sky wrote:

I audited a quick for the rest: `sizeof`/`alignof` are spec'd for references and the evaluator strips them itself, `__builtin_omp_required_simd_align` only looks at the target, and `_Countof` is C-only.

`vec_step` and ptrauth do have the same issue, just silent: `vec_step(float4&)` returns 1 instead of 4 in C++ for OpenCL, and `__builtin_ptrauth_type_discriminator(void (S::*&)())` gives a different value than the pointee. Both pre-existing I believe.  What do you think?


https://github.com/llvm/llvm-project/pull/219767


More information about the cfe-commits mailing list