translate-c reject structs with VLAs

This commit is contained in:
Vexu
2020-03-08 12:07:26 +02:00
parent 5aa993cd61
commit 692a974c3e
5 changed files with 42 additions and 3 deletions

View File

@@ -1881,6 +1881,26 @@ bool ZigClangType_isRecordType(const ZigClangType *self) {
return casted->isRecordType();
}
bool ZigClangType_isIncompleteOrZeroLengthArrayType(const ZigClangQualType *self,
const struct ZigClangASTContext *ctx)
{
auto casted_ctx = reinterpret_cast<const clang::ASTContext *>(ctx);
auto casted = reinterpret_cast<const clang::QualType *>(self);
auto casted_type = reinterpret_cast<const clang::Type *>(self);
if (casted_type->isIncompleteArrayType())
return true;
clang::QualType elem_type = *casted;
while (const clang::ConstantArrayType *ArrayT = casted_ctx->getAsConstantArrayType(elem_type)) {
if (ArrayT->getSize() == 0)
return true;
elem_type = ArrayT->getElementType();
}
return false;
}
bool ZigClangType_isConstantArrayType(const ZigClangType *self) {
auto casted = reinterpret_cast<const clang::Type *>(self);
return casted->isConstantArrayType();