[clang][Interp] Fix Descriptor::getElemQualType() for complex/vectors

We handle them like arrays but still need to differentiate between
array/vector/complex types when dealing with QualTypes.
This commit is contained in:
Timm Bäder 2024-06-20 16:19:02 +02:00
parent 0255c48188
commit ae41232191
2 changed files with 18 additions and 2 deletions

View File

@ -359,8 +359,14 @@ QualType Descriptor::getType() const {
QualType Descriptor::getElemQualType() const {
assert(isArray());
const auto *AT = cast<ArrayType>(getType());
return AT->getElementType();
QualType T = getType();
if (const auto *AT = T->getAsArrayTypeUnsafe())
return AT->getElementType();
if (const auto *CT = T->getAs<ComplexType>())
return CT->getElementType();
if (const auto *CT = T->getAs<VectorType>())
return CT->getElementType();
llvm_unreachable("Array that's not an array/complex/vector type?");
}
SourceLocation Descriptor::getLocation() const {

View File

@ -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];
}