Fix a crash in constant evaluation of ExtVectorElementExprs (#136771)

Handle the case where the base expression is a pointer to a vector type.

rdar://149223362
This commit is contained in:
Akira Hatanaka
2025-04-24 08:47:29 -07:00
committed by GitHub
parent 2ca071b1de
commit feaa5aa840
2 changed files with 6 additions and 1 deletions

View File

@@ -9202,7 +9202,10 @@ bool LValueExprEvaluator::VisitExtVectorElementExpr(
if (Success) {
Result.setFrom(Info.Ctx, Val);
const auto *VT = E->getBase()->getType()->castAs<VectorType>();
QualType BaseType = E->getBase()->getType();
if (E->isArrow())
BaseType = BaseType->getPointeeType();
const auto *VT = BaseType->castAs<VectorType>();
HandleLValueVectorElement(Info, E, Result, VT->getElementType(),
VT->getNumElements(), Indices[0]);
}

View File

@@ -43,4 +43,6 @@ static_assert(b.lo.lo == 1); // expected-error {{not an integral constant expres
// make sure clang rejects taking address of a vector element
static_assert(&b[1]); // expected-error {{address of vector element requested}}
constexpr const FourIntsExtVec *p = &b;
static_assert(p->x == 1);
}