From ab5d9228e05b105adcfdadd382fce9bfcdd486dd Mon Sep 17 00:00:00 2001
From: BenceJanosSzabo <bence.janos.szabo@ericsson.com>
Date: Mon, 4 Sep 2017 15:33:20 +0200
Subject: [PATCH] XER: embed value supporting field cannot be attribute (Bug
 521828)

Change-Id: Id7bd6e7c13bdb6a6a6fbc04caf94d16e8cdcd299
Signed-off-by: BenceJanosSzabo <bence.janos.szabo@ericsson.com>
---
 compiler2/Type_chk.cc                         | 11 +++++++-
 .../xer/emb_first_attrib_SE.ttcn              | 26 +++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 function_test/Semantic_Analyser/xer/emb_first_attrib_SE.ttcn

diff --git a/compiler2/Type_chk.cc b/compiler2/Type_chk.cc
index 1a2c80f87..0b760a2a5 100644
--- a/compiler2/Type_chk.cc
+++ b/compiler2/Type_chk.cc
@@ -1489,7 +1489,7 @@ void Type::chk_xer_embed_values(int num_attributes)
 
   enum complaint_type { ALL_GOOD, HAVE_DEFAULT, UNTAGGED_EMBEDVAL,
     NOT_SEQUENCE, EMPTY_SEQUENCE, FIRST_NOT_SEQOF, SEQOF_NOT_STRING,
-    SEQOF_BAD_LENGTH, UNTAGGED_OTHER } ;
+    SEQOF_BAD_LENGTH, UNTAGGED_OTHER, ATTRIBUTE_EMBEDVAL } ;
   complaint_type complaint = ALL_GOOD;
   size_t expected_length = (size_t)-1;
   Type *cf0t = 0; // type of first component
@@ -1519,6 +1519,12 @@ void Type::chk_xer_embed_values(int num_attributes)
           complaint = UNTAGGED_EMBEDVAL; // 25.2.2
           break;
         }
+        // Either the type of the field or the last_refd type of the field
+        if ((cf0->get_type()->xerattrib && cf0->get_type()->xerattrib->attribute_)
+          || (cf0t->xerattrib && cf0t->xerattrib->attribute_)) {
+          complaint = ATTRIBUTE_EMBEDVAL;
+          break;
+        }
 
         // Check length restriction on the record of. If there is one,
         // it better be the correct number.
@@ -1589,6 +1595,9 @@ void Type::chk_xer_embed_values(int num_attributes)
       cf->error("There shall be no UNTAGGED on any character-encodable "
         "component of a type with DEFAULT-FOR-EMPTY"); // 25.2.3
       break;
+    case ATTRIBUTE_EMBEDVAL:
+      error("The SEQUENCE-OF supporting EMBED-VALUES must not have ATTRIBUTE.");
+      break;
     } // switch(complaint)
   } // if complaint and embedValues
 }
diff --git a/function_test/Semantic_Analyser/xer/emb_first_attrib_SE.ttcn b/function_test/Semantic_Analyser/xer/emb_first_attrib_SE.ttcn
new file mode 100644
index 000000000..bda0fd684
--- /dev/null
+++ b/function_test/Semantic_Analyser/xer/emb_first_attrib_SE.ttcn
@@ -0,0 +1,26 @@
+/******************************************************************************
+ * Copyright (c) 2000-2017 Ericsson Telecom AB
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Szabo, Bence Janos
+ *
+ ******************************************************************************/
+module emb_first_attrib_SE {	//^In TTCN-3 module `emb_first_attrib_SE'://
+
+type record e1 { //^In type definition// //^error: The SEQUENCE\-OF supporting EMBED\-VALUES must not have ATTRIBUTE\.//
+  record of universal charstring field_1 
+}
+with {
+  variant "embedValues"
+  variant (field_1) "attribute"
+}
+
+
+}
+with {
+encode "XML"
+}
-- 
GitLab