diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/TypeMerging.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/passes/TypeMerging.cpp b/src/passes/TypeMerging.cpp index 94a198adf..0fc766f4e 100644 --- a/src/passes/TypeMerging.cpp +++ b/src/passes/TypeMerging.cpp @@ -149,22 +149,21 @@ struct TypeMerging : public Pass { continue; } - // TODO: arrays - if (!type.isStruct()) { - continue; - } - - auto& fields = type.getStruct().fields; - auto& superFields = super->getStruct().fields; - if (fields != superFields) { - // This adds a field, or refines one, so it differs from the super, and - // we cannot merge it with the super. - continue; + if (type.isStruct()) { + auto& fields = type.getStruct().fields; + auto& superFields = super->getStruct().fields; + if (fields == superFields) { + // We can merge! This is identical structurally to the super, and also + // not distinguishable nominally. + merges[type] = *super; + } + } else if (type.isArray()) { + auto element = type.getArray().element; + auto superElement = super->getArray().element; + if (element == superElement) { + merges[type] = *super; + } } - - // We can merge! This is identical structurally to the super, and also not - // distinguishable nominally. - merges[type] = *super; } if (merges.empty()) { |