From 923482f7eacbc0b71c942a78b4dafc39e536e53e Mon Sep 17 00:00:00 2001
From: Botond Baranyi <botond.baranyi@ericsson.com>
Date: Mon, 15 Jul 2019 17:26:20 +0200
Subject: [PATCH] Fixed type descriptor generation for anytypes (bug 549218)

Change-Id: Ie85957c595308861d25398772db336a39781fd4a
Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com>
---
 compiler2/Type.cc         | 3 ++-
 compiler2/Type_codegen.cc | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/compiler2/Type.cc b/compiler2/Type.cc
index 35ffd9672..10acf4423 100644
--- a/compiler2/Type.cc
+++ b/compiler2/Type.cc
@@ -7494,6 +7494,7 @@ namespace Common {
   string Type::get_genname_typedescriptor(Scope *p_scope)
   {
     Type *t = this;
+    bool is_anytype = get_type_refd_last()->typetype == T_ANYTYPE;
     for ( ; ; ) {
       /* If it has tags or encoding attributes, then its encoding may be
        * different from the other "equivalent" types and needs to have its own
@@ -7501,7 +7502,7 @@ namespace Common {
        */
       if (t->is_tagged() || t->rawattrib || t->textattrib || t->jsonattrib ||
           (!t->is_asn1() && t->hasEncodeAttr(get_encoding_name(CT_JSON))) ||
-          (t->xerattrib && !t->xerattrib->empty() ) ||
+          (!is_anytype && t->xerattrib && !t->xerattrib->empty() ) ||
           (asn1_xer && t->is_asn1() && t->ownertype != OT_RECORD_OF && t->ownertype != OT_REF_SPEC) ||
           (t->oerattrib && !t->oerattrib->empty() && t->is_asn1()))
       {
diff --git a/compiler2/Type_codegen.cc b/compiler2/Type_codegen.cc
index 222887bb6..574cd68a6 100644
--- a/compiler2/Type_codegen.cc
+++ b/compiler2/Type_codegen.cc
@@ -433,7 +433,7 @@ void Type::generate_code_typedescriptor(output_struct *target)
     
     if (T_SEQOF == last->typetype || T_SETOF == last->typetype) {
       target->source.global_vars=mputprintf(target->source.global_vars,
-        "&%s_descr_, ", get_type_refd_last()->u.seof.ofType->get_genname_typedescriptor(my_scope).c_str());
+        "&%s_descr_, ", last->u.seof.ofType->get_genname_typedescriptor(my_scope).c_str());
     }
     else {
       target->source.global_vars = mputstr(target->source.global_vars,
-- 
GitLab