Skip to content

Commit 609c72c

Browse files
Ailuridaeaardappel
andauthored
[C++] Fixes #8446 (#8447)
Fixes access to union members when generating code with options "--cpp-field-case-style upper" and "--gen-object-api" Co-authored-by: Wouter van Oortmerssen <[email protected]>
1 parent bd1b2d0 commit 609c72c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/idl_gen_cpp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3193,7 +3193,7 @@ class CppGenerator : public BaseGenerator {
31933193
const char *vec_type_access) {
31943194
auto type_name = WrapInNameSpace(*afield.value.type.enum_def);
31953195
return type_name + "Union::UnPack(" + "_e" + vec_elem_access + ", " +
3196-
EscapeKeyword(afield.name + UnionTypeFieldSuffix()) + "()" +
3196+
EscapeKeyword(Name(afield) + UnionTypeFieldSuffix()) + "()" +
31973197
vec_type_access + ", _resolver)";
31983198
}
31993199

@@ -3339,7 +3339,7 @@ class CppGenerator : public BaseGenerator {
33393339
BASE_TYPE_UNION);
33403340
// Generate code that sets the union type, of the form:
33413341
// _o->field.type = _e;
3342-
code += "_o->" + union_field->name + ".type = _e;";
3342+
code += "_o->" + Name(*union_field) + ".type = _e;";
33433343
break;
33443344
}
33453345
case BASE_TYPE_UNION: {

0 commit comments

Comments
 (0)