From 2417b71cf86b5e9f10a7ecc0bca1443a16733566 Mon Sep 17 00:00:00 2001 From: BenceJanosSzabo <bence.janos.szabo@ericsson.com> Date: Fri, 16 Dec 2016 15:25:37 +0100 Subject: [PATCH] Added more info about enc/dec problem (artf190389) Change-Id: Ieac0cd9a6c1aca8ade00cfae5785d9757897604a Signed-off-by: BenceJanosSzabo <bence.janos.szabo@ericsson.com> --- compiler2/ttcn3/AST_ttcn3.cc | 29 ++++++++- .../encode/encode_ttcn_SE.ttcn | 61 +++++++++++++++++++ 2 files changed, 88 insertions(+), 2 deletions(-) diff --git a/compiler2/ttcn3/AST_ttcn3.cc b/compiler2/ttcn3/AST_ttcn3.cc index 27b188442..008b08571 100644 --- a/compiler2/ttcn3/AST_ttcn3.cc +++ b/compiler2/ttcn3/AST_ttcn3.cc @@ -6550,9 +6550,34 @@ namespace Ttcn { input_type->get_typename().c_str(), encoding_options->c_str()); } else { - input_type->error("Input type `%s' does not support %s encoding", + // First collect the fields of a record, set, union type which + // does not support the encoding, then write it in the error message. + char* message = NULL; + Type *t = input_type; + if (t->is_ref()) t = t->get_type_refd(); + switch(t->get_typetype()) { + case Type::T_SEQ_T: + case Type::T_SET_T: + case Type::T_CHOICE_T: { + for (size_t i = 0; i < t->get_nof_comps(); i++) { + if (!t->get_comp_byIndex(i)->get_type()->has_encoding(encoding_type, encoding_options)) { + if (i == 0) { + message = mputprintf(message, " The following fields do not support %s encoding: ", + Type::get_encoding_name(encoding_type)); + } else { + message = mputstr(message, ", "); + } + message = mputstr(message, t->get_comp_id_byIndex(i).get_ttcnname().c_str()); + } + } + break; } + default: + break; + } + input_type->error("Input type `%s' does not support %s encoding.%s", input_type->get_typename().c_str(), - Type::get_encoding_name(encoding_type)); + Type::get_encoding_name(encoding_type), message == NULL ? "" : message); + Free(message); } } else { diff --git a/function_test/Semantic_Analyser/encode/encode_ttcn_SE.ttcn b/function_test/Semantic_Analyser/encode/encode_ttcn_SE.ttcn index e59db46b6..2c52a9da4 100644 --- a/function_test/Semantic_Analyser/encode/encode_ttcn_SE.ttcn +++ b/function_test/Semantic_Analyser/encode/encode_ttcn_SE.ttcn @@ -89,6 +89,67 @@ external function f_enc_arr1(in AnArray x) return bitstring external function f_enc_arr2(in AnArray x) return bitstring with { extension "prototype(convert) encode(codec3)" } +type record A { + integer a +} + +type record B { + integer b +} + +type record C { + A a, + B b +} with { + encode "XML"; +} + +type union D { + A a, + B b +} with { + encode "XML"; +} + +type set E { + A a, + B b +} with { + encode "XML"; +} + +external function f_enc_C(in C x) return octetstring //^In external function definition \`f_enc_C\'\:// //^error\: Input type \`\@encode_ttcn_SE\.C\' does not support XER encoding\. The following fields do not support XER encoding\: a\, b// + with { extension "prototype(convert) encode(XER:XER_EXTENDED)" }; + +external function f_enc_D(in D x) return octetstring //^In external function definition \`f_enc_D\'\:// //^error\: Input type \`\@encode_ttcn_SE\.D\' does not support XER encoding\. The following fields do not support XER encoding\: a\, b// + with { extension "prototype(convert) encode(XER:XER_EXTENDED)" }; + +external function f_enc_E(in E x) return octetstring //^In external function definition \`f_enc_E\'\:// //^error\: Input type \`\@encode_ttcn_SE\.E\' does not support XER encoding\. The following fields do not support XER encoding\: a\, b// + with { extension "prototype(convert) encode(XER:XER_EXTENDED)" }; + +external function f_enc_A(in A x) return octetstring //^In external function definition \`f_enc_A\'\:// //^error\: Input type \`\@encode_ttcn_SE\.A\' does not support XER encoding\.// + with { extension "prototype(convert) encode(XER:XER_EXTENDED)" }; + +type record A2 { + integer a +} with { + encode "XML"; +} + +type record B2 { + integer b +} with { + encode "XML"; +} + +type record C2 { + A a, + B b +} + +external function f_enc_C2(in C2 x) return octetstring //^In external function definition \`f_enc_C2\'\:// //^error\: Input type \`\@encode_ttcn_SE\.C2\' does not support XER encoding\.// + with { extension "prototype(convert) encode(XER:XER_EXTENDED)" }; + } with { encode "whatever" -- GitLab