diff --git a/compiler2/Type.cc b/compiler2/Type.cc index 67ebfa64239f1e0039395d8b02d1a52e6f39d932..1885e5d2f99e7d05257bb9c3fba12bd0a1264f3e 100644 --- a/compiler2/Type.cc +++ b/compiler2/Type.cc @@ -3255,7 +3255,7 @@ namespace Common { case T_ANY: return p_tt2 == T_ANY || p_tt2 == T_OSTR; case T_ANYTYPE: - return p_tt2 == T_ANYTYPE && same_module; + return p_tt2 == T_ANYTYPE && same_module; // Need same module // these should never appear? case T_REFD: case T_REFDSPEC: @@ -3284,8 +3284,8 @@ namespace Common { default: { bool same_mod = false; if (p_type && p_type->get_my_scope()) { - if (t1->get_my_scope()->get_scope_mod()->get_modid().get_name() == - p_type->get_my_scope()->get_scope_mod()->get_modid().get_name()) { + if (t1->get_my_scope()->get_scope_mod() == + p_type->get_my_scope()->get_scope_mod()) { same_mod = true; } } diff --git a/compiler2/Type.hh b/compiler2/Type.hh index 877de1462868681a1ab488e6ed14a96cbfccc9c1..1715ce1ff14d1dda8b69a292e63fe73deea1cb4a 100644 --- a/compiler2/Type.hh +++ b/compiler2/Type.hh @@ -582,7 +582,8 @@ namespace Common { /** Return whether the two typetypes are compatible. Sometimes, this is * just a question of \p p_tt1 == \p p_tt2. When there are multiple * typetypes for a type (e.g. T_ENUM_A and T_ENUM_T) then all - * combinations of those are compatible. */ + * combinations of those are compatible. In case of anytype the + * module has to be the same */ static bool is_compatible_tt_tt(typetype_t p_tt1, typetype_t p_tt2, bool p_is_asn11, bool p_is_asn12, bool same_module); diff --git a/compiler2/Type_chk.cc b/compiler2/Type_chk.cc index 408788382634ead36ff492ea7b179d5912e5edb4..e0453be498839f35bdd05fe668c8d105dc9f783b 100644 --- a/compiler2/Type_chk.cc +++ b/compiler2/Type_chk.cc @@ -3227,7 +3227,7 @@ bool Type::chk_this_value(Value *value, Common::Assignment *lhs, expected_value_ return chk_this_refd_value(value, lhs, expected_value, 0, is_str_elem); case Value::V_INVOKE: chk_this_invoked_value(value, lhs, expected_value); - return false; // assumes no self-ref in invoke + return false; // assumes no self-reference in invoke case Value::V_EXPR: if (lhs) self_ref = value->chk_expr_self_ref(lhs); // no break diff --git a/compiler2/Value.cc b/compiler2/Value.cc index f0d3715cd1590ba5c50c8f5585776b6ef33b9da1..eec4887ffc116eda5db817373427e736241968e5 100644 --- a/compiler2/Value.cc +++ b/compiler2/Value.cc @@ -4234,6 +4234,7 @@ namespace Common { } // Deny type compatibility if no governors found. The typetype_t must // be the same. TODO: How can this happen? + // Default false the 5th param if (!Type::is_compatible_tt_tt(tt1, tt2, false, false, false) && !Type::is_compatible_tt_tt(tt2, tt1, false, false, false)) { error("The operands of operation `%s' should be of compatible types", diff --git a/compiler2/ttcn3/AST_ttcn3.cc b/compiler2/ttcn3/AST_ttcn3.cc index f31abf996ec521d201a0971f606c6f57619d424c..3d10a8b06fab7efad5d56152b143371e3ef1bbb0 100644 --- a/compiler2/ttcn3/AST_ttcn3.cc +++ b/compiler2/ttcn3/AST_ttcn3.cc @@ -6665,8 +6665,11 @@ namespace Ttcn { if (Common::Type::CT_XER == encoding_type) { Type* last = input_type->get_type_refd_last(); if (last->is_untagged() && - last->get_typetype() == Type::T_CHOICE_A || last->get_typetype() == Type::T_CHOICE_T) { - // "untagged" on the (toplevel) input type will have no effect unless it is union + last->get_typetype() != Type::T_CHOICE_A && + last->get_typetype() != Type::T_CHOICE_T && + last->get_typetype() != Type::T_ANYTYPE) { + // "untagged" on the (toplevel) input type will have no effect, + // unless it is union or anytype warning("UNTAGGED encoding attribute is ignored on top-level type"); } } diff --git a/function_test/Semantic_Analyser/xer/untagged_charenc_optional_SE.ttcn b/function_test/Semantic_Analyser/xer/untagged_charenc_optional_SE.ttcn index 58cf7495e8b648b60742ea5ac61f36e98c22a1ed..a28a1a98a06c34ed16020cc1f3e68ab8f513f44a 100644 --- a/function_test/Semantic_Analyser/xer/untagged_charenc_optional_SE.ttcn +++ b/function_test/Semantic_Analyser/xer/untagged_charenc_optional_SE.ttcn @@ -8,6 +8,7 @@ * Contributors: * Balasko, Jeno * Raduly, Csaba + * Szabo, Bence Janos * ******************************************************************************/ module untagged_charenc_optional_SE { //^In TTCN-3 module `untagged_charenc_optional_SE':// @@ -32,7 +33,21 @@ type record parent2 { unt trouble optional // no message } +type union uni { + integer i +} with { + variant "untagged"; +} + +// No top level untagged warning for unions and anytype +external function enc_uni(in uni u) return octetstring +with { extension "prototype(convert) encode(XER:XER_EXTENDED)" } + +external function enc_anytype(in anytype u) return octetstring +with { extension "prototype(convert) encode(XER:XER_EXTENDED)" } + } with { encode "XML"; +extension "anytype integer"; }