From 7ea388195c520f7e348fa84471f9301c5af504e6 Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 12 Dec 2024 10:20:18 +0100 Subject: [PATCH] [C++] Fixes #8446 Fixes access to union members when generating code with options "--cpp-field-case-style upper" and "--gen-object-api" --- src/idl_gen_cpp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp index 06571693286..98212fba7f9 100644 --- a/src/idl_gen_cpp.cpp +++ b/src/idl_gen_cpp.cpp @@ -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)"; } @@ -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: {