[clang] [clang][Sema] Allow splat initialization of a sizeless vector in a C++ code (PR #205432)
Paul Osmialowski via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 23 15:56:40 PDT 2026
================
@@ -1484,8 +1484,32 @@ void InitListChecker::CheckListElementTypes(const InitializedEntity &Entity,
} else if (DeclType->isOCLIntelSubgroupAVCType() ||
DeclType->isSizelessBuiltinType()) {
// Checks for scalar type are sufficient for these types too.
- CheckScalarType(Entity, IList, DeclType, Index, StructuredList,
- StructuredIndex);
+ Expr *expr =
+ (Index < IList->getNumInits()) ? IList->getInit(Index) : nullptr;
+ // Prevent splat when doing list initialization.
+ if (expr && expr->getType()->isArithmeticType() &&
+ DeclType->isSizelessVectorType()) {
+ if (!VerifyOnly) {
+ if (SemaRef.Context.getLangOpts().CPlusPlus) {
+ PartialDiagnostic PDiag =
+ SemaRef.PDiag(diag::err_init_conversion_failed)
+ << (int)Entity.getKind() << DeclType << expr->isLValue()
----------------
pawosm-arm wrote:
changed to `static_cast<int>`
https://github.com/llvm/llvm-project/pull/205432
More information about the cfe-commits
mailing list