From dda7d42422fad3c5262d7b87c965024a25e4b9cb Mon Sep 17 00:00:00 2001 From: Botond Baranyi <botond.baranyi@ericsson.com> Date: Tue, 5 May 2020 19:36:57 +0200 Subject: [PATCH] Minor OOP fixes Change-Id: If4373d02526f3b377b46828ba8e49bcd1e273ab8 Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com> --- compiler2/ttcn3/AST_ttcn3.cc | 18 +++++++----------- .../Semantic_Analyser/Makefile.semantic | 2 +- .../Semantic_Analyser/oop/oop_SE.ttcn | 4 ++-- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/compiler2/ttcn3/AST_ttcn3.cc b/compiler2/ttcn3/AST_ttcn3.cc index 7363b51d6..1a4481507 100644 --- a/compiler2/ttcn3/AST_ttcn3.cc +++ b/compiler2/ttcn3/AST_ttcn3.cc @@ -1418,7 +1418,9 @@ namespace Ttcn { Common::Assignment *RunsOnScope::get_ass_bySRef(Ref_simple *p_ref) { if (!p_ref) FATAL_ERROR("Ttcn::RunsOnScope::get_ass_bySRef()"); - if (p_ref->get_modid()) return parent_scope->get_ass_bySRef(p_ref); + if (p_ref->get_modid() || p_ref->get_reftype() != Ref_simple::REF_BASIC) { + return parent_scope->get_ass_bySRef(p_ref); + } else { const Identifier& id = *p_ref->get_id(); if (component_defs->has_local_ass_withId(id)) { @@ -3667,12 +3669,6 @@ namespace Ttcn { delete t; continue; } - else if (t->get_type_refd_last()->get_typetype() == Type::T_CLASS) { - ea.error("Class type `%s' cannot be added to the anytype", - t->get_typename().c_str()); - delete t; - continue; - } string field_name; const char* btn = Type::get_typename_builtin(t->get_typetype()); @@ -4206,6 +4202,10 @@ namespace Ttcn { error("Type of module parameter cannot be signature `%s'", t->get_fullname().c_str()); break; + case Type::T_CLASS: + error("Type of module parameter cannot be or embed class type `%s'", + t->get_fullname().c_str()); + break; case Type::T_FUNCTION: case Type::T_ALTSTEP: case Type::T_TESTCASE: @@ -4214,10 +4214,6 @@ namespace Ttcn { " `%s' which has runs on self clause", t->get_fullname().c_str()); break; } - case Type::T_CLASS: - error("Type of module parameter cannot be or embed class type `%s'", - t->get_fullname().c_str()); - break; default: #if defined(MINGW) checked = true; diff --git a/function_test/Semantic_Analyser/Makefile.semantic b/function_test/Semantic_Analyser/Makefile.semantic index 5fc093bc2..e36e6ad41 100644 --- a/function_test/Semantic_Analyser/Makefile.semantic +++ b/function_test/Semantic_Analyser/Makefile.semantic @@ -16,7 +16,7 @@ include ../../Makefile.personal SADIRS := ver param template any_from pattern_ref float recof_index \ port_translation mtc_and_system_clause port_map_connect deterministic invoking_function_from_specific_places \ -json realtime map_param +json realtime map_param oop ifdef RT2 SADIRS += deprecated erroneous_attributes template_concat endif diff --git a/function_test/Semantic_Analyser/oop/oop_SE.ttcn b/function_test/Semantic_Analyser/oop/oop_SE.ttcn index 42a4732a5..b7d6129fe 100644 --- a/function_test/Semantic_Analyser/oop/oop_SE.ttcn +++ b/function_test/Semantic_Analyser/oop/oop_SE.ttcn @@ -159,7 +159,7 @@ function f_embedded_types() { //^In function definition// var SetOfClass v_setof := { C0.create }; var UniClass v_uni := { x := C0.create }; var anytype v_any; //^In variable definition// //^In type definition// - v_any.C0 := C0.create; //^In variable assignment// //Reference to non-existent field `C0' in type `@oop_SE.anytype'// + v_any.C0 := C0.create; } @@ -213,5 +213,5 @@ type class C10 runs on CT_RunsOn mtc CT_Mtc system CT_System { //^In type defini } with { - extension "anytype C0" //Class type `@oop_SE.C0' cannot be added to the anytype// + extension "anytype C0" //^In anytype field// //Class type `@oop_SE.C0' cannot be embedded into another type// } -- GitLab