================ @@ -14017,6 +14017,24 @@ void Sema::CheckCastAlign(Expr *Op, QualType T, SourceRange TRange) { << TRange << Op->getSourceRange(); } +void Sema::CheckVectorAccess(const Expr *BaseExpr, const Expr *IndexExpr) { + const VectorType *VTy = BaseExpr->getType()->getAs<VectorType>(); + if (!VTy) + return; + + Expr::EvalResult Result; + if (!IndexExpr->EvaluateAsInt(Result, Context, Expr::SE_AllowSideEffects)) + return; + + unsigned DiagID = getLangOpts().HLSL ? diag::err_vector_index_out_of_range + : diag::warn_vector_index_out_of_range; ---------------- svenvh wrote:
Vector subscripts aren't in the OpenCL C specification indeed, though clang has always silently supported them. I'm not sure if any OpenCL users are relying on this functionality, but in my opinion a compile-time provable out-of-bounds access is worth reporting. So I'm okay if you enable this for OpenCL. https://github.com/llvm/llvm-project/pull/128952 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits