From 816843f2a5775ee0d176667a36bc1bd691d17b5b Mon Sep 17 00:00:00 2001
From: Botond Baranyi <botond.baranyi@ericsson.com>
Date: Wed, 16 May 2018 12:48:44 +0200
Subject: [PATCH] Fixed RT2 template error reporting and removed some warnings

Change-Id: Ib4550683ed9c1200743a28c25820a52482378306
Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com>
---
 compiler2/ttcn3/Statement.cc | 4 ++--
 core/OER.hh                  | 4 ++--
 core/Template.cc             | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/compiler2/ttcn3/Statement.cc b/compiler2/ttcn3/Statement.cc
index cb87d8ee4..863cab051 100644
--- a/compiler2/ttcn3/Statement.cc
+++ b/compiler2/ttcn3/Statement.cc
@@ -3579,7 +3579,7 @@ error:
   {
     Error_Context cntxt(this, "In send statement");
     // checking the port reference
-    Type *port_type;
+    Type *port_type = NULL;
     if (port_op.translate) {
       PortScope* ps = my_sb->get_scope_port();
       if (ps) {
@@ -3973,7 +3973,7 @@ error:
     const char *stmt_name = get_stmt_name();
     Error_Context cntxt(this, "In %s statement", stmt_name);
     // checking the port reference
-    Type *port_type;
+    Type *port_type = NULL;
     if (port_op.translate) {
       PortScope* ps = my_sb->get_scope_port();
       if (ps) {
diff --git a/core/OER.hh b/core/OER.hh
index ccf29fb64..5267760e7 100644
--- a/core/OER.hh
+++ b/core/OER.hh
@@ -16,8 +16,8 @@
 #include "Vector.hh"
 
 class TTCN_Buffer;
-class ASN_BERdescriptor_t;
-class ASN_Tag_t;
+struct ASN_BERdescriptor_t;
+struct ASN_Tag_t;
 
 struct TTCN_OERdescriptor_t 
 {
diff --git a/core/Template.cc b/core/Template.cc
index cde7b9793..5c990d773 100644
--- a/core/Template.cc
+++ b/core/Template.cc
@@ -2838,12 +2838,12 @@ Base_Template* Record_Template::get_at(int index_value)
 
 const Base_Template* Record_Template::get_at(int index_value) const
 {
-  if (index_value < 0 || index_value >= single_value.n_elements)
-    TTCN_error("Internal error: accessing an element of a template of type %s using an "
-      "invalid index: %d.", get_descriptor()->name, index_value);
   if (template_selection != SPECIFIC_VALUE)
     TTCN_error("Accessing field %s of a non-specific template of type %s.",
                fld_name(index_value), get_descriptor()->name);
+  if (index_value < 0 || index_value >= single_value.n_elements)
+    TTCN_error("Internal error: accessing an element of a template of type %s using an "
+      "invalid index: %d.", get_descriptor()->name, index_value);
   return single_value.value_elements[index_value];
 }
 
-- 
GitLab