diff --git a/compiler2/ttcn3/AST_ttcn3.cc b/compiler2/ttcn3/AST_ttcn3.cc
index 27b188442e872e05e8d8458e80989b63743cb091..008b08571330784769452c8f0c3637521fe9d726 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 e59db46b6ce82dc2b88bc28a161614a2d2768068..2c52a9da4b06e442f5a831e6577374821862658c 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"