From 4981e77beae07ec4de72c2136932bdb0eb18ab25 Mon Sep 17 00:00:00 2001
From: Botond Baranyi <botond.baranyi@ericsson.com>
Date: Wed, 18 Nov 2020 17:37:57 +0100
Subject: [PATCH] Added semantic error for using class method return values as
 'out' / 'inout' parameters (bug 563718)

Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com>
Change-Id: I44fcec14ed30d7adb99ba2f9acc2889893e40114
---
 compiler2/ttcn3/AST_ttcn3.cc                    | 4 ++--
 function_test/Semantic_Analyser/oop/oop_SE.ttcn | 9 ++++++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/compiler2/ttcn3/AST_ttcn3.cc b/compiler2/ttcn3/AST_ttcn3.cc
index 0291a21a0..0a3aa0ec1 100644
--- a/compiler2/ttcn3/AST_ttcn3.cc
+++ b/compiler2/ttcn3/AST_ttcn3.cc
@@ -971,7 +971,7 @@ namespace Ttcn {
 
   Type *Reference::chk_variable_ref()
   {
-    Common::Assignment *t_ass = get_refd_assignment();
+    Common::Assignment *t_ass = get_refd_assignment_last();
     if (!t_ass) return 0;
     switch (t_ass->get_asstype()) {
     case Common::Assignment::A_PAR_VAL_IN:
@@ -9570,7 +9570,7 @@ namespace Ttcn {
     Template *ap_template = actual_par->get_Template();
     if (ap_template->is_Ref()) {
       Reference *ref = ap_template->get_Ref();
-      Common::Assignment *ass = ref->get_refd_assignment();
+      Common::Assignment *ass = ref->get_refd_assignment_last();
       if (!ass) {
         delete ref;
         return new ActualPar();
diff --git a/function_test/Semantic_Analyser/oop/oop_SE.ttcn b/function_test/Semantic_Analyser/oop/oop_SE.ttcn
index ce1962687..2fde4a63a 100644
--- a/function_test/Semantic_Analyser/oop/oop_SE.ttcn
+++ b/function_test/Semantic_Analyser/oop/oop_SE.ttcn
@@ -470,7 +470,7 @@ type class C46 extends object { }
 
 type class C47 {
   const integer m1 := 3;
-  function m2() return boolean { return true; }
+  public function m2() return boolean { return true; }
   function m3(in integer p) return charstring { return int2str(p); }
   function @final m4() { }
 }
@@ -517,6 +517,13 @@ function f_casting() { //^In function definition//
   var integer x7 := x1 => (x6); //^In variable definition// //^In the second operand of operation `=>'// //Class type was expected//
 }
 
+function f_parameters(in boolean p1, inout boolean p2, out boolean p3) { }
+
+function f_param_test() { //^In function definition//
+  var C47 x := C47.create(1);
+  f_parameters(x.m2(), x.m2(), x.m2()); //^In function instance// //^In actual parameter list of function// //^In parameter #2// //^In parameter #3// //Reference to a variable or value parameter was expected for an \`inout\' value parameter instead of function// //Reference to a variable or value parameter was expected for an \`out\' value parameter instead of function//
+}
+
 
 control { //^In control part//
   var C11 x := C11.create; //^In variable definition// //A definition without `runs on' clause cannot create a value of class type `@oop_SE.C11', which runs on component type `@oop_SE.CT_RunsOn'// //Cannot create value of class type `@oop_SE.C11', which has an `mtc' clause, in the control part.// //Cannot create value of class type `@oop_SE.C11', which has a `system' clause, in the control part.//
-- 
GitLab