From fff7715f201a7a8503c4638d3ae1627ccd09589c Mon Sep 17 00:00:00 2001 From: Botond Baranyi <botond.baranyi@ericsson.com> Date: Wed, 21 Apr 2021 18:00:49 +0200 Subject: [PATCH] Added missing semantic errors to the create operation (bug 568899) Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com> --- compiler2/Value.cc | 17 +++++++++++++---- function_test/Semantic_Analyser/oop/oop_SE.ttcn | 7 +++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/compiler2/Value.cc b/compiler2/Value.cc index e0d0a4068..355c5a9c2 100644 --- a/compiler2/Value.cc +++ b/compiler2/Value.cc @@ -5144,7 +5144,8 @@ namespace Common { // convert the parameter list to component 'create' parameters size_t nof_pars = u.expr.t_list2->get_nof_tis(); if (nof_pars > 2) { - // error + u.expr.t_list2->error("Operation `create' for a component type cannot have more than 2 parameters"); + goto error; } else { Value* name_val = NULL; @@ -5157,7 +5158,9 @@ namespace Common { name_val = name_par->get_Template()->get_Value(); } else { - // error + name_par->error("A specific value without matching symbols was expected for the " + "first parameter of operation `create'"); + goto error; } } if (nof_pars == 2) { @@ -5168,7 +5171,12 @@ namespace Common { loc_val = loc_par->get_Template()->get_Value(); } else { - // error + loc_par->error("A specific value without matching symbols was expected for the " + "second parameter of operation `create'"); + if (name_val != NULL) { + delete name_val; + } + goto error; } } } @@ -5181,7 +5189,8 @@ namespace Common { } else { // T_CLASS if (u.expr.b4) { // 'alive' keyword is set - // error + error("Keyword `alive' cannot be used when creating an object of class type"); + goto error; } u.expr.v_optype = OPTYPE_CLASS_CREATE; } diff --git a/function_test/Semantic_Analyser/oop/oop_SE.ttcn b/function_test/Semantic_Analyser/oop/oop_SE.ttcn index 02872e813..21c0007bc 100644 --- a/function_test/Semantic_Analyser/oop/oop_SE.ttcn +++ b/function_test/Semantic_Analyser/oop/oop_SE.ttcn @@ -338,6 +338,13 @@ type class C20 extends C15 { //^In type definition// create() : f_embedded_types() { } //^In constructor definition// //^In super-constructor call// //Reference to constructor was expected instead of function// } +function f_create() { //^In function definition// + var C0 x1 := C0.create alive; //^In variable definition// //Keyword `alive' cannot be used when creating an object of class type// + var Comp c1 := Comp.create("a", "b", "c"); //^In variable definition// //Operation `create' for a component type cannot have more than 2 parameters// + var Comp c2 := Comp.create(? length (3)); //^In variable definition// //A specific value without matching symbols was expected for the first parameter of operation `create'// + var Comp c3 := Comp.create("a", *); //^In variable definition// //A specific value without matching symbols was expected for the second parameter of operation `create'// +} + type class @final @abstract C21 { } //^In type definition// //Final classes cannot be abstract// -- GitLab