aboutsummaryrefslogtreecommitdiff
path: root/src/zig_clang.cpp
diff options
context:
space:
mode:
authorVexu <git@vexu.eu>2020-03-08 12:07:26 +0200
committerVexu <git@vexu.eu>2020-03-08 12:11:37 +0200
commit692a974c3edd05944d33cd579bcb355cdd7199fc (patch)
tree029600d5411dfd9c6b8b64b2c0c3df58ac3f340a /src/zig_clang.cpp
parent5aa993cd617e0ae3cabc9c626e45a748857e2f2a (diff)
downloadzig-692a974c3edd05944d33cd579bcb355cdd7199fc.tar.gz
zig-692a974c3edd05944d33cd579bcb355cdd7199fc.zip
translate-c reject structs with VLAs
Diffstat (limited to 'src/zig_clang.cpp')
-rw-r--r--src/zig_clang.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/zig_clang.cpp b/src/zig_clang.cpp
index 8a1baa2d49..c5ea182e87 100644
--- a/src/zig_clang.cpp
+++ b/src/zig_clang.cpp
@@ -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();