Skip to content

Commit

Permalink
Fix for arrays of unions/structs in union cases
Browse files Browse the repository at this point in the history
Arrays of unions/structs in union cases, did not retrieve the entity
properties for the streaming function, resulting in a failure to
compile

Signed-off-by: Martijn Reicher <[email protected]>
  • Loading branch information
reicheratwork authored and eboasson committed Apr 4, 2022
1 parent 4833704 commit cfe8ea3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/ddscxx/tests/Regression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ TEST_F(Regression, direct_typedef_of_primitive)
readwrite_test(s, s_td_bool_seq_arr_bytes, basic_cdr_stream(endianness::little_endian));
}

TEST_F(Regression, union_array_case)
{
s_u_struct_arr z;
}

TEST_F(Regression, direct_typedef_of_struct)
{
u_s_inner u;
Expand Down
7 changes: 7 additions & 0 deletions src/ddscxx/tests/data/RegressionModels.idl
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,11 @@ typedef sequence<e1, 3> seq_e1;
@optional seq_e1 c;
};

union u_struct_arr switch (unsigned long) {
case 0: s_inner c_1[1];
};
@appendable @topic struct s_u_struct_arr {
u_struct_arr c;
};

};
4 changes: 2 additions & 2 deletions src/idlcxx/src/streamers.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ process_case(

bool single = (idl_degree(_case->labels) == 1) && !(idl_mask(_case->labels) == IDL_DEFAULT_CASE_LABEL),
simple = (idl_is_base_type(_case->type_spec) || idl_is_bitmask(_case->type_spec)) && !idl_is_array(_case->declarator),
constructed_type = idl_is_constr_type(_case->type_spec) && !idl_is_enum(_case->type_spec) && !idl_is_array(_case->declarator) && !idl_is_bitmask(_case->type_spec);
constructed_type = idl_is_constr_type(_case->type_spec) && !idl_is_enum(_case->type_spec) && !idl_is_bitmask(_case->type_spec);
instance_location_t loc = { .parent = "instance", .type = UNION_BRANCH };

static const char *max_start =
Expand Down Expand Up @@ -915,7 +915,7 @@ process_case(
if (multi_putf(streams, READ, check_props))
return IDL_RETCODE_NO_MEMORY;

if (multi_putf(streams, (WRITE | MOVE), " break; }\n")
if (multi_putf(streams, (WRITE | MOVE), " }\n break;\n")
|| putf(&streams->read, read_end, name)
|| putf(&streams->max, max_end))
return IDL_RETCODE_NO_MEMORY;
Expand Down

0 comments on commit cfe8ea3

Please sign in to comment.