Skip to content

Commit

Permalink
[C++] Fixes google#8446
Browse files Browse the repository at this point in the history
Fixes access to union members when generating code with options "--cpp-field-case-style upper" and "--gen-object-api"
  • Loading branch information
Ailuridae committed Dec 12, 2024
1 parent 1f4a903 commit 7ea3881
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/idl_gen_cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3193,7 +3193,7 @@ class CppGenerator : public BaseGenerator {
const char *vec_type_access) {
auto type_name = WrapInNameSpace(*afield.value.type.enum_def);
return type_name + "Union::UnPack(" + "_e" + vec_elem_access + ", " +
EscapeKeyword(afield.name + UnionTypeFieldSuffix()) + "()" +
EscapeKeyword(Name(afield) + UnionTypeFieldSuffix()) + "()" +
vec_type_access + ", _resolver)";
}

Expand Down Expand Up @@ -3338,7 +3338,7 @@ class CppGenerator : public BaseGenerator {
BASE_TYPE_UNION);
// Generate code that sets the union type, of the form:
// _o->field.type = _e;
code += "_o->" + union_field->name + ".type = _e;";
code += "_o->" + Name(*union_field) + ".type = _e;";
break;
}
case BASE_TYPE_UNION: {
Expand Down

0 comments on commit 7ea3881

Please sign in to comment.