Skip to content

Commit 45c31c7

Browse files
Copilotmouse07410
andcommitted
Fix tests-c-compiler failures by including ENUMERATED types in suffix logic
The previous fix for duplicate member names was missing ENUMERATED types, causing member table references to use unsuffixed names for anonymous ENUMERATED members in SET OF/SEQUENCE OF constructs. This broke tests like check-70 where "SET OF ENUMERATED" generated asn_DEF_Member_N but referenced asn_DEF_Member. Fixed by also checking for ASN_BASIC_ENUMERATED in the suffix condition, matching the complex_contents definition which includes both constructed types (ASN_CONSTR_MASK) and ENUMERATED types. Regenerated test expectations to reflect correct suffixed references for embedded ENUMERATED types. Co-authored-by: mouse07410 <[email protected]>
1 parent c9784f3 commit 45c31c7

14 files changed

+24
-25
lines changed

libasn1compiler/asn1c_C.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3844,10 +3844,9 @@ emit_member_table(arg_t *arg, asn1p_expr_t *expr, asn1c_ioc_table_and_objset_t *
38443844
/*
38453845
* Use suffix when:
38463846
* - It's an open type (always embedded with suffix)
3847-
* - Member is embedded (has parent_expr) and not anonymous, as embedded
3848-
* types use static storage and need unique suffixes to avoid runtime
3849-
* ambiguity when same member name appears in different parents with
3850-
* different type definitions
3847+
* - Member is embedded (has parent_expr), as embedded types use static
3848+
* storage and get suffixes to avoid runtime ambiguity when same member
3849+
* name appears in different parents with different type definitions
38513850
* - Global defs flag is set (all types get suffixes)
38523851
*
38533852
* Note: We check expr->parent_expr instead of HIDE_INNER_DEFS because
@@ -3856,7 +3855,7 @@ emit_member_table(arg_t *arg, asn1p_expr_t *expr, asn1c_ioc_table_and_objset_t *
38563855
* was generated with static storage.
38573856
*/
38583857
if(is_open_type(arg, expr, opt_ioc) || (arg->flags & A1C_ALL_DEFS_GLOBAL) ||
3859-
(expr->parent_expr && !expr->_anonymous_type && (expr->expr_type & ASN_CONSTR_MASK))) {
3858+
(expr->parent_expr && ((expr->expr_type & ASN_CONSTR_MASK) || expr->expr_type == ASN_BASIC_ENUMERATED))) {
38603859
OUT("_%d", expr->_type_unique_index);
38613860
}
38623861
OUT(",\n");

tests/tests-asn1c-compiler/110-param-3-OK.asn1.+-P_-fcompound-names

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ asn_TYPE_member_t asn_MBR_Flag_15P1_6[] = {
238238
{ ATF_POINTER, 1, offsetof(struct Flag_15P1, field),
239239
.tag = (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)),
240240
.tag_mode = 0,
241-
.type = &asn_DEF_field,
241+
.type = &asn_DEF_field_7,
242242
.type_selector = 0,
243243
{
244244
#if !defined(ASN_DISABLE_OER_SUPPORT)

tests/tests-asn1c-compiler/158-sequence-of-sequence-nested-OK.asn1.+-P_-fcompound-names

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static asn_TYPE_member_t asn_MBR_SeqWithNestedSOS__sos__Member__nested_sos_6[] =
141141
{ ATF_POINTER, 0, 0,
142142
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
143143
.tag_mode = 0,
144-
.type = &asn_DEF_Member,
144+
.type = &asn_DEF_Member_7,
145145
.type_selector = 0,
146146
{
147147
#if !defined(ASN_DISABLE_OER_SUPPORT)
@@ -285,7 +285,7 @@ static asn_TYPE_member_t asn_MBR_SeqWithNestedSOS__sos_3[] = {
285285
{ ATF_POINTER, 0, 0,
286286
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
287287
.tag_mode = 0,
288-
.type = &asn_DEF_Member,
288+
.type = &asn_DEF_Member_4,
289289
.type_selector = 0,
290290
{
291291
#if !defined(ASN_DISABLE_OER_SUPPORT)

tests/tests-asn1c-compiler/178-nested-enum-same-name-OK.asn1.+-P_-fcompound-names

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ static asn_TYPE_member_t asn_MBR_CodebookConfig_r18__codebookType__type2__typeII
279279
{ ATF_NOFLAGS, 0, offsetof(struct CodebookConfig_r18__codebookType__type2__typeII_CJT_r18, restrictedCMR_Selection_r18),
280280
.tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
281281
.tag_mode = -1, /* IMPLICIT tag at current level */
282-
.type = &asn_DEF_restrictedCMR_Selection_r18,
282+
.type = &asn_DEF_restrictedCMR_Selection_r18_6,
283283
.type_selector = 0,
284284
{
285285
#if !defined(ASN_DISABLE_OER_SUPPORT)
@@ -423,7 +423,7 @@ static asn_TYPE_member_t asn_MBR_CodebookConfig_r18__codebookType__type2__typeII
423423
{ ATF_NOFLAGS, 0, offsetof(struct CodebookConfig_r18__codebookType__type2__typeII_CJT_PortSelection_r18, restrictedCMR_Selection_r18),
424424
.tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
425425
.tag_mode = -1, /* IMPLICIT tag at current level */
426-
.type = &asn_DEF_restrictedCMR_Selection_r18,
426+
.type = &asn_DEF_restrictedCMR_Selection_r18_10,
427427
.type_selector = 0,
428428
{
429429
#if !defined(ASN_DISABLE_OER_SUPPORT)

tests/tests-asn1c-compiler/179-sequence-of-in-choice-OK.asn1.+-P_-fcompound-names

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ static asn_TYPE_member_t asn_MBR_TestMessage__content__type2Bit_3[] = {
293293
{ ATF_POINTER, 0, 0,
294294
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
295295
.tag_mode = 0,
296-
.type = &asn_DEF_Member,
296+
.type = &asn_DEF_Member_4,
297297
.type_selector = 0,
298298
{
299299
#if !defined(ASN_DISABLE_OER_SUPPORT)
@@ -437,7 +437,7 @@ static asn_TYPE_member_t asn_MBR_TestMessage__content__type4Bit_7[] = {
437437
{ ATF_POINTER, 0, 0,
438438
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
439439
.tag_mode = 0,
440-
.type = &asn_DEF_Member,
440+
.type = &asn_DEF_Member_8,
441441
.type_selector = 0,
442442
{
443443
#if !defined(ASN_DISABLE_OER_SUPPORT)
@@ -916,7 +916,7 @@ static asn_TYPE_member_t asn_MBR_DeepNesting__nested__branch1__items_4[] = {
916916
{ ATF_POINTER, 0, 0,
917917
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
918918
.tag_mode = 0,
919-
.type = &asn_DEF_Member,
919+
.type = &asn_DEF_Member_5,
920920
.type_selector = 0,
921921
{
922922
#if !defined(ASN_DISABLE_OER_SUPPORT)
@@ -1125,7 +1125,7 @@ static asn_TYPE_member_t asn_MBR_DeepNesting__nested__branch2__items_9[] = {
11251125
{ ATF_POINTER, 0, 0,
11261126
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
11271127
.tag_mode = 0,
1128-
.type = &asn_DEF_Member,
1128+
.type = &asn_DEF_Member_10,
11291129
.type_selector = 0,
11301130
{
11311131
#if !defined(ASN_DISABLE_OER_SUPPORT)

tests/tests-asn1c-compiler/31-set-of-OK.asn1.+-P_-fcompound-names

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ static asn_TYPE_member_t asn_MBR_Stuff__anything_8[] = {
532532
{ ATF_POINTER, 0, 0,
533533
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
534534
.tag_mode = 0,
535-
.type = &asn_DEF_Member,
535+
.type = &asn_DEF_Member_9,
536536
.type_selector = 0,
537537
{
538538
#if !defined(ASN_DISABLE_OER_SUPPORT)

tests/tests-asn1c-compiler/31-set-of-OK.asn1.+-P_-fwide-types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ static asn_TYPE_member_t asn_MBR_Stuff__anything_8[] = {
532532
{ ATF_POINTER, 0, 0,
533533
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
534534
.tag_mode = 0,
535-
.type = &asn_DEF_Member,
535+
.type = &asn_DEF_Member_9,
536536
.type_selector = 0,
537537
{
538538
#if !defined(ASN_DISABLE_OER_SUPPORT)

tests/tests-asn1c-compiler/42-real-life-OK.asn1.+-P_-R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ asn_TYPE_member_t asn_MBR_ActionItem_1[] = {
10851085
{ ATF_NOFLAGS, 0, offsetof(struct ActionItem, accept_as),
10861086
.tag = (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)),
10871087
.tag_mode = 0,
1088-
.type = &asn_DEF_accept_as,
1088+
.type = &asn_DEF_accept_as_2,
10891089
.type_selector = 0,
10901090
{
10911091
#if !defined(ASN_DISABLE_OER_SUPPORT)

tests/tests-asn1c-compiler/50-constraint-OK.asn1.+-P_-fwide-types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2474,7 +2474,7 @@ asn_TYPE_member_t asn_MBR_Sequence_1[] = {
24742474
{ ATF_NOFLAGS, 0, offsetof(struct Sequence, enum_c),
24752475
.tag = (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)),
24762476
.tag_mode = 0,
2477-
.type = &asn_DEF_enum_c,
2477+
.type = &asn_DEF_enum_c_6,
24782478
.type_selector = 0,
24792479
{
24802480
#if !defined(ASN_DISABLE_OER_SUPPORT)

tests/tests-asn1c-compiler/50-constraint-OK.asn1.+-P_-gen-UPER_-gen-APER

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2817,7 +2817,7 @@ asn_TYPE_member_t asn_MBR_Sequence_1[] = {
28172817
{ ATF_NOFLAGS, 0, offsetof(struct Sequence, enum_c),
28182818
.tag = (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)),
28192819
.tag_mode = 0,
2820-
.type = &asn_DEF_enum_c,
2820+
.type = &asn_DEF_enum_c_6,
28212821
.type_selector = 0,
28222822
{
28232823
#if !defined(ASN_DISABLE_OER_SUPPORT)

0 commit comments

Comments
 (0)