make unions with type aliases more usable (#5019)

Some generic C++ and Rust code is not generated when unions use type
aliases because of potential ambiguity. Actually check for this
ambiguity and only disable offending code only if it is found.
This commit is contained in:
Frank Benkstein
2018-11-01 20:51:25 +01:00
committed by Wouter van Oortmerssen
parent 4c3b6c247d
commit 91fe9ba93f
33 changed files with 1773 additions and 37 deletions

View File

@@ -327,7 +327,7 @@ struct EnumVal {
};
struct EnumDef : public Definition {
EnumDef() : is_union(false), uses_type_aliases(false) {}
EnumDef() : is_union(false), uses_multiple_type_instances(false) {}
EnumVal *ReverseLookup(int64_t enum_idx, bool skip_union_default = true) {
for (auto it = vals.vec.begin() +
@@ -342,7 +342,9 @@ struct EnumDef : public Definition {
SymbolTable<EnumVal> vals;
bool is_union;
bool uses_type_aliases;
// Type is a union which uses type aliases where at least one type is
// available under two different names.
bool uses_multiple_type_instances;
Type underlying_type;
};