diff --git a/clang/lib/AST/Interp/Descriptor.cpp b/clang/lib/AST/Interp/Descriptor.cpp index d20ab1340c89..fcb778f7aeab 100644 --- a/clang/lib/AST/Interp/Descriptor.cpp +++ b/clang/lib/AST/Interp/Descriptor.cpp @@ -359,8 +359,14 @@ QualType Descriptor::getType() const { QualType Descriptor::getElemQualType() const { assert(isArray()); - const auto *AT = cast(getType()); - return AT->getElementType(); + QualType T = getType(); + if (const auto *AT = T->getAsArrayTypeUnsafe()) + return AT->getElementType(); + if (const auto *CT = T->getAs()) + return CT->getElementType(); + if (const auto *CT = T->getAs()) + return CT->getElementType(); + llvm_unreachable("Array that's not an array/complex/vector type?"); } SourceLocation Descriptor::getLocation() const { diff --git a/clang/test/AST/Interp/vectors.cpp b/clang/test/AST/Interp/vectors.cpp index 61c400b57b3f..6991a348b07a 100644 --- a/clang/test/AST/Interp/vectors.cpp +++ b/clang/test/AST/Interp/vectors.cpp @@ -81,3 +81,13 @@ namespace VectorElementExpr { static_assert(twoElts.x == 22, ""); // ref-error {{not an integral constant expression}} static_assert(twoElts.y == 33, ""); // ref-error {{not an integral constant expression}} } + +namespace Temporaries { + typedef __attribute__((vector_size(16))) int vi4a; + typedef __attribute__((ext_vector_type(4))) int vi4b; + struct S { + vi4a v; + vi4b w; + }; + int &&s = S().w[1]; +}