Inconsistent subtype code in SEQUENCE
escmmo opened this issue · comments
asn1scc version 4.5.0.10
Defining a member of a SEQUENCE from a subtype (SubA) of a subtype (A) will produce code that bypasses (SubA) and uses (A) directly. If a subtype (X) of (SubA) is defined, it will generate code using (SubA) as expected.
Source .asn:
TypeA ::= SEQUENCE
{
x INTEGER(0..255)
}
TypeSubA ::= TypeA
TypeX ::= TypeSubA
TypeY ::= SEQUENCE
{
c TypeSubA
}
Source .acn:
TypeA []
{
x [],
y NULL [pattern '1111'B]
}
TypeSubA []
{
x [],
y NULL [pattern '0000'B]
}
Source for TypeX:
flag TypeX_IsConstraintValid(const TypeX* pVal, int* pErrCode)
{
flag ret = TRUE;
ret = TypeSubA_IsConstraintValid(pVal, pErrCode);
return ret;
}
void TypeX_Initialize(TypeX* pVal)
{
(void)pVal;
TypeSubA_Initialize(pVal);
}
flag TypeX_ACN_Encode(const TypeX* pVal, BitStream* pBitStrm, int* pErrCode, flag bCheckConstraints)
{
flag ret = TRUE;
*pErrCode = 0;
ret = bCheckConstraints ? TypeX_IsConstraintValid(pVal, pErrCode) : TRUE ;
if (ret && *pErrCode == 0) {
ret = TypeSubA_ACN_Encode(pVal, pBitStrm, pErrCode, FALSE);
} /*COVERAGE_IGNORE*/
return ret;
}
flag TypeX_ACN_Decode(TypeX* pVal, BitStream* pBitStrm, int* pErrCode)
{
flag ret = TRUE;
*pErrCode = 0;
ret = TypeSubA_ACN_Decode(pVal, pBitStrm, pErrCode);
return ret && TypeX_IsConstraintValid(pVal, pErrCode);
}
Source for TypeY:
flag TypeY_IsConstraintValid(const TypeY* pVal, int* pErrCode)
{
flag ret = TRUE;
ret = TypeA_IsConstraintValid((&(pVal->c)), pErrCode);
return ret;
}
void TypeY_Initialize(TypeY* pVal)
{
(void)pVal;
/*set c */
TypeA_Initialize((&(pVal->c)));
}
flag TypeY_ACN_Encode(const TypeY* pVal, BitStream* pBitStrm, int* pErrCode, flag bCheckConstraints)
{
flag ret = TRUE;
*pErrCode = 0;
ret = bCheckConstraints ? TypeY_IsConstraintValid(pVal, pErrCode) : TRUE ;
if (ret && *pErrCode == 0) {
/*Encode c */
ret = TypeA_ACN_Encode((&(pVal->c)), pBitStrm, pErrCode, FALSE);
} /*COVERAGE_IGNORE*/
return ret;
}
flag TypeY_ACN_Decode(TypeY* pVal, BitStream* pBitStrm, int* pErrCode)
{
flag ret = TRUE;
*pErrCode = 0;
/*Decode c */
ret = TypeA_ACN_Decode((&(pVal->c)), pBitStrm, pErrCode);
return ret && TypeY_IsConstraintValid(pVal, pErrCode);
}
Acknowledged, we are looking into it