diff --git a/common/Makefile b/common/Makefile index a590616eaab728084925a52de74fd502c8f694d5..663d212839189e54f45771218d04d5233c0bb0e4 100644 --- a/common/Makefile +++ b/common/Makefile @@ -36,7 +36,7 @@ GENERATED_SOURCES := pattern_la.cc pattern_p.cc pattern_uni.cc config_preproc_la # Sources in the CVS STATIC_SOURCES := memory.c new.cc userinfo.c path.c config_preproc.cc Quadruple.cc \ - Path2.cc ModuleVersion.cc JSON_Tokenizer.cc UnicharPattern.cc + Path2.cc ModuleVersion.cc JSON_Tokenizer.cc UnicharPattern.cc openssl_version.c ifndef MINGW STATIC_SOURCES += NetworkHandler.cc diff --git a/common/license.c b/common/license.c index eb476e9a9830bdb865d6ffdf149683f92d7c7cc2..7aa9efb2c63707c1d35a5031e749eaea67b60617 100644 --- a/common/license.c +++ b/common/license.c @@ -489,10 +489,6 @@ void free_openssl() ERR_free_strings(); } -const char * openssl_version_str(void) { - return SSLeay_version(SSLEAY_VERSION); -} - #if defined(WIN32) || defined(INTERIX) #ifdef INTERIX diff --git a/common/license.h b/common/license.h index 32d015199880e88e28975525d21af119f0496b62..13d648f5d1cb426ef7aaf34c431c2e1046931443 100644 --- a/common/license.h +++ b/common/license.h @@ -150,8 +150,6 @@ void print_license_info(void); void init_openssl(void); void free_openssl(void); -const char * openssl_version_str(void); - #if defined(WIN32) || defined(INTERIX) long gethostid(void); #endif diff --git a/common/openssl_version.c b/common/openssl_version.c new file mode 100644 index 0000000000000000000000000000000000000000..7542c0fe0b41912fdda995be8400e11f2f5399e9 --- /dev/null +++ b/common/openssl_version.c @@ -0,0 +1,18 @@ +/****************************************************************************** + * Copyright (c) 2000-2016 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 + * + ******************************************************************************/ + +#include "openssl_version.h" +#include <openssl/crypto.h> + +const char * openssl_version_str(void) { + return SSLeay_version(SSLEAY_VERSION); +} diff --git a/common/openssl_version.h b/common/openssl_version.h new file mode 100644 index 0000000000000000000000000000000000000000..9a98a573a2b50cf4f4065fddcbb3c6f4ecde47da --- /dev/null +++ b/common/openssl_version.h @@ -0,0 +1,25 @@ +/****************************************************************************** + * Copyright (c) 2000-2016 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 + * + ******************************************************************************/ +#ifndef OPENSSL_VERSION_H +#define OPENSSL_VERSION_H + +#ifdef __cplusplus +extern "C" { +#endif + +const char * openssl_version_str(void); + +#ifdef __cplusplus +} +#endif + +#endif // OPENSSL_VERSION_H diff --git a/common/ttcn3float.hh b/common/ttcn3float.hh index ba67e29324bb53a4413c1fd1bbfd292a0ff2481c..13fbba3c63208b10be941e6bbc47a737ba480613 100644 --- a/common/ttcn3float.hh +++ b/common/ttcn3float.hh @@ -24,9 +24,9 @@ #define MAX_DECIMAL_FLOAT 1.0E+10 #ifndef signbit - Probably Solaris. - Thankfully, IEEE Std 1003.1, 2004 Edition says that signbit is a macro, - hence it's safe to use ifdef. +// Probably Solaris. +// Thankfully, IEEE Std 1003.1, 2004 Edition says that signbit is a macro, +// hence it's safe to use ifdef. #ifdef __sparc // Big endian @@ -37,7 +37,7 @@ inline int signbitfunc(double d) } #else - Probably Intel, assume little endian +// Probably Intel, assume little endian inline int signbitfunc(double d) { return ((unsigned char*)&d)[sizeof(double)-1] & 0x80; diff --git a/compiler2/Makefile b/compiler2/Makefile index d00ff26bdb63eb779b44405c35645452b0efe5d1..dcf2ca5f863a228b1370a713ff4a6acd53beaf7c 100644 --- a/compiler2/Makefile +++ b/compiler2/Makefile @@ -112,8 +112,8 @@ COMMON_OBJECTS := $(addprefix ../common/, memory.o path.o userinfo.o) TCOV2LCOV_COMMON_OBJECTS := ../common/memory.o ifeq ($(LICENSING), yes) - COMMON_OBJECTS += ../common/license.o - TCOV2LCOV_COMMON_OBJECTS += ../common/license.o + COMMON_OBJECTS += ../common/license.o + TCOV2LCOV_COMMON_OBJECTS += ../common/license.o endif ifdef REGEX_DIR @@ -122,7 +122,7 @@ endif COMPILER_COMMON_OBJECTS := $(COMMON_OBJECTS) \ $(addprefix ../common/, new.o pattern_la.o pattern_p.o pattern_uni.o Quadruple.o \ -ModuleVersion.o JSON_Tokenizer.o UnicharPattern.o) +ModuleVersion.o JSON_Tokenizer.o UnicharPattern.o openssl_version.o) ifeq ($(USAGE_STATS), yes) COMPILER_COMMON_OBJECTS += ../common/usage_stats.o diff --git a/compiler2/Value.cc b/compiler2/Value.cc index ead10d58b41a332f0f689bf6303ba5967f375da4..f3f1c912ea4ed2506c9e65ec49f575bd7c154d24 100644 --- a/compiler2/Value.cc +++ b/compiler2/Value.cc @@ -9103,12 +9103,26 @@ error: ReferenceChain *refch, bool silent) { Value *v_index = array_index->get_value_refd_last(refch); + if (!my_governor) FATAL_ERROR("Value::get_refd_field_value()"); + Type *t = my_governor->get_type_refd_last(); Int index = 0; bool index_available = false; if (!v_index->is_unfoldable()) { if (v_index->valuetype == V_INT) { index = v_index->get_val_Int()->get_val(); index_available = true; + } else if (v_index->valuetype == V_ARRAY || v_index->valuetype == V_SEQOF) { + Value *v = this; + size_t comps = v_index->get_nof_comps(); + for (size_t i = 0; i < comps; i++) { + Value *comp = v_index->get_comp_byIndex(i); + v = v->get_refd_array_value(comp, usedInIsbound, refch, silent); + if (v == NULL) { + // error reported already + return 0; + } + } + return v; } else if (!silent) { array_index->error("An integer value or a fixed length array or record of integer value was expected as index"); } @@ -9120,8 +9134,7 @@ error: } return 0; } - if (!my_governor) FATAL_ERROR("Value::get_refd_field_value()"); - Type *t = my_governor->get_type_refd_last(); + switch (t->get_typetype()) { case Type::T_ERROR: // remain silent diff --git a/compiler2/main.cc b/compiler2/main.cc index f00d8ab444f6f87ad8208866a96e16582c20df97..c7eaa508adfbf72fb767bc1be0fc280f584c428a 100644 --- a/compiler2/main.cc +++ b/compiler2/main.cc @@ -69,6 +69,8 @@ #include "ttcn3/profiler.h" +#include "../common/openssl_version.h" + #ifdef LICENSE #include "../common/license.h" #endif @@ -919,12 +921,12 @@ int main(int argc, char *argv[]) fputs("TTCN-3 and ASN.1 Compiler for the TTCN-3 Test Executor\n" "Product number: " PRODUCT_NUMBER "\n" "Build date: " __DATE__ " " __TIME__ "\n" - "Compiled with: " C_COMPILER_VERSION "\n\n" - COPYRIGHT_STRING "\n\n", stderr); + "Compiled with: " C_COMPILER_VERSION "\n", stderr); + fputs("Using ", stderr); + fputs(openssl_version_str(), stderr); + fputs("\n\n" COPYRIGHT_STRING "\n\n", stderr); #ifdef LICENSE print_license_info(); - fputs("\nUsing ", stderr); - fputs(openssl_version_str(), stderr); fputs("\n\n", stderr); #endif return EXIT_SUCCESS; diff --git a/function_test/Semantic_Analyser/recof_index/recof_index_SE.ttcn b/function_test/Semantic_Analyser/recof_index/recof_index_SE.ttcn index 42fc6cfcea51c325a54831f9b25923eb1681e5b3..349116aa69ea3661cdec566ff4183bceba67b70e 100644 --- a/function_test/Semantic_Analyser/recof_index/recof_index_SE.ttcn +++ b/function_test/Semantic_Analyser/recof_index/recof_index_SE.ttcn @@ -11,10 +11,13 @@ ******************************************************************************/ module recof_index_SE { //^In TTCN-3 module// + type set of set of integer SoSoI; type record of record of integer RoRoI; + type record length(1) of integer RoIOne; type record length(1..2) of integer RoI1; type record length(3) of integer RoI2; type record of integer RoI; + type set of integer SoI; type record length(1) of float RoF1; @@ -47,4 +50,41 @@ module recof_index_SE { //^In TTCN-3 module// } + const RoRoI c_roiroi1 := {{1,2}, {3,4}} + + const RoIOne c_roi := {3}; //error\: Index overflow in a value of \`record of\' type \`\@recof_index_SE\.RoRoI\'\: the index is 3\, but the value has only 2 elements// + const RoI c_roi_err := c_roiroi1[c_roi]; //^In constant definition \`c_roi_err\'\:// + + const RoIOne c_roi2 := {4}; //error\: Index overflow in a value of \`record of\' type \`\@recof_index_SE\.RoRoI\.SEQUENCE_OF\'\: the index is 4\, but the value has only 2 elements// + const integer c_int_err := c_roiroi1[1][c_roi2]; //^In constant definition \`c_int_err\'\:// + + const RoI2 c_roi3 := {1,1,1}; //error\: Invalid array element reference\: type \`integer\' cannot be indexed// + const integer c_int_err2 := c_roiroi1[c_roi3]; //In constant definition \`c_int_err2\'\:// + + + const SoSoI c_soisoi1 := {{1,2}, {3,4}} + + const RoIOne c_roi4 := {3}; //error\: Index overflow in a value of \`set of\' type \`\@recof_index_SE\.SoSoI\'\: the index is 3\, but the value has only 2 elements// + const SoI c_soi_err := c_soisoi1[c_roi4]; //^In constant definition \`c_soi_err\'\:// + + const RoIOne c_roi5 := {4}; //error\: Index overflow in a value of \`set of\' type \`\@recof_index_SE\.SoSoI\.SET_OF\'\: the index is 4\, but the value has only 2 elements// + const integer c_int_err3 := c_soisoi1[1][c_roi5]; //^In constant definition \`c_int_err3\'\:// + + const RoI2 c_roi6 := {1,1,1}; //error\: Invalid array element reference\: type \`integer\' cannot be indexed// + const integer c_int_err4 := c_soisoi1[c_roi6]; //In constant definition \`c_int_err4\'\:// + + + const integer c_arrarr1[2][2] := {{1,2}, {3,4}} + + const RoIOne c_roi7 := {3}; //error\: Array index overflow\: the index value must be at most \`1\' instead of \`3\'// + const integer c_arr_err[2] := c_arrarr1[c_roi7]; //^In constant definition \`c_arr_err\'\:// + + const RoIOne c_roi8 := {4}; //error\: Array index overflow\: the index value must be at most \`1\' instead of \`4\'// + const integer c_int_err5 := c_arrarr1[1][c_roi8]; //^In constant definition \`c_int_err5\'\:// + + const RoI2 c_roi9 := {1,1,1}; //error\: Invalid array element reference\: type \`integer\' cannot be indexed// + const integer c_int_err6 := c_arrarr1[c_roi9]; //In constant definition \`c_int_err6\'\:// + + + } diff --git a/mctr2/mctr/Makefile b/mctr2/mctr/Makefile index e49f8be38c5258f545334061a5f90f776d9b6bd5..4de56af22c2051e244b5ea39cc4c75ea3ade8da1 100644 --- a/mctr2/mctr/Makefile +++ b/mctr2/mctr/Makefile @@ -55,7 +55,7 @@ OBJECTS_NOMAIN := $(filter-out Cli_main.o, $(OBJECTS)) COMMON_OBJECTS := $(addprefix ../../common/, memory.o config_preproc.o \ config_preproc_la.o config_preproc_p.tab.o path.o NetworkHandler.o \ -Path2.o) ../../core/RInt.o ../../core/Textbuf.o +Path2.o openssl_version.o) ../../core/RInt.o ../../core/Textbuf.o ifeq ($(LICENSING), yes) COMMON_OBJECTS += ../../common/license.o diff --git a/mctr2/mctr/main.cc b/mctr2/mctr/main.cc index 83a9e1dd19578cad0bff901f85291b157cae54f5..5cfe7d910afffe9c59f1680492083b4ef8257916 100644 --- a/mctr2/mctr/main.cc +++ b/mctr2/mctr/main.cc @@ -49,6 +49,8 @@ #include "../../common/license.h" #endif +#include "../../common/openssl_version.h" + #include "MainController.h" #if defined CLI @@ -273,12 +275,12 @@ int main(int argc, char *argv[]) " for the TTCN-3 Test Executor\n" "Product number: " PRODUCT_NUMBER "\n" "Build date: " __DATE__ " " __TIME__ "\n" - "Compiled with: " C_COMPILER_VERSION "\n\n" - COPYRIGHT_STRING "\n\n", stderr); + "Compiled with: " C_COMPILER_VERSION "\n", stderr); + fputs("Using ", stderr); + fputs(openssl_version_str(), stderr); + fputs("\n\n" COPYRIGHT_STRING "\n\n", stderr); #ifdef LICENSE print_license_info(); - fputs("\nUsing ", stderr); - fputs(openssl_version_str(), stderr); fputs("\n\n", stderr); #endif return 0; diff --git a/regression_test/indexWithRecofArray/IndexWithRecofArray.ttcn b/regression_test/indexWithRecofArray/IndexWithRecofArray.ttcn index c759c8b8c2fc226f48702b26dc57a01f4e1763bb..de629004ed8670513ac77afccb6c3e159f1737c4 100644 --- a/regression_test/indexWithRecofArray/IndexWithRecofArray.ttcn +++ b/regression_test/indexWithRecofArray/IndexWithRecofArray.ttcn @@ -16,12 +16,16 @@ module IndexWithRecofArray { } + type record of integer RoI; + type set of integer SoI; type record of record of integer RoRoI; type record of record of RoRoI RoIRoIRoIRoI; type set of set of integer SoISoI; type set of set of SoISoI SoISoISoISoI type record length(1) of integer RoI1; type record length(2) of integer RoI2; + type integer IntArr1[1]; + type integer IntArr2[2]; //###########################################################################// @@ -1668,6 +1672,268 @@ module IndexWithRecofArray { v_arr[v_index2] := "d"; } + +//###########################################################################// +// Constants indexing + + const RoRoI c_rois := {{1,2,3}, {4,5,6}}; + + const RoI1 c_roi1_1 := {0}; + const RoI1 c_roi1_2 := {1}; + + const RoI2 c_roi2_1 := {0, 2}; + const RoI2 c_roi2_2 := {1, 2} + + const RoI c_roi_1 := c_rois[c_roi1_1]; // {1,2,3} + const RoI c_roi_2 := c_rois[c_roi1_2]; // {4,5,6} + + const IntArr1 c_intarr_1 := {0}; + const IntArr1 c_intarr_2 := {1}; + + const integer c_int_1 := c_rois[c_roi2_1]; // 3 + const integer c_int_2 := c_rois[c_roi2_2]; // 6 + const integer c_int_3 := c_rois[c_roi1_1][c_roi1_1]; // 1 + const integer c_int_4 := c_rois[c_roi1_1][2]; // 3 + const integer c_int_5 := c_rois[1][c_roi1_1]; // 4 + + const integer c_int_6 := c_rois[c_intarr_1][c_intarr_1]; // 1 + const integer c_int_7 := c_rois[c_intarr_1][c_roi1_1]; // 1 + const integer c_int_8 := c_rois[c_intarr_1][1]; // 2 + + + testcase tc_const_record_of_indexing() runs on GeneralComp { + if (c_roi_1 == {1,2,3}) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_roi_2 == {4,5,6}) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_1 == 3) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_2 == 6) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_3 == 1) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_4 == 3) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_5 == 4) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_6 == 1) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_7 == 1) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_8 == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + } + + + const SoISoI c_sois := {{1,2,3}, {4,5,6}}; + const SoI c_soi_1 := c_sois[c_roi1_1]; // {1,2,3} + const SoI c_soi_2 := c_sois[c_roi1_2]; // {4,5,6} + + const integer c_int_9 := c_sois[c_roi2_1]; // 3 + const integer c_int_10 := c_sois[c_roi2_2]; // 6 + const integer c_int_11 := c_sois[c_roi1_1][c_roi1_1]; // 1 + const integer c_int_12 := c_sois[c_roi1_1][2]; // 3 + const integer c_int_13 := c_sois[1][c_roi1_1]; // 4 + + const integer c_int_14 := c_sois[c_intarr_1][c_intarr_1]; // 1 + const integer c_int_15 := c_sois[c_intarr_1][c_roi1_1]; // 1 + const integer c_int_16 := c_sois[c_intarr_1][1]; // 2 + + + testcase tc_const_set_of_indexing() runs on GeneralComp { + if (c_soi_1 == {1,2,3}) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_soi_2 == {4,5,6}) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_9 == 3) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_10 == 6) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_11 == 1) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_12 == 3) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_13 == 4) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_14 == 1) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_15 == 1) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_16 == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + } + + const integer c_arrarr[2][3] := {{1,2,3}, {4,5,6}} + + const integer c_arr_0[3] := c_arrarr[c_roi1_1]; // {1,2,3} + const integer c_arr_1[3] := c_arr_0; + const integer c_arr_2[3] := c_arrarr[c_roi1_2]; // {4,5,6} + + const integer c_int_17 := c_arrarr[c_roi2_1]; // 3 + const integer c_int_18 := c_arrarr[c_roi2_2]; // 6 + const integer c_int_19 := c_arrarr[c_roi1_1][c_roi1_1]; // 1 + const integer c_int_20 := c_arrarr[c_roi1_1][2]; // 3 + const integer c_int_21 := c_arrarr[1][c_roi1_1]; // 4 + + const integer c_int_22 := c_arrarr[c_intarr_1][c_intarr_1]; // 1 + const integer c_int_23 := c_arrarr[c_intarr_1][c_roi1_1]; // 1 + const integer c_int_24 := c_arrarr[c_intarr_1][1]; // 2 + + + const integer c_arrarr_1[2..3][4..6] := {{1,2,3}, {4,5,6}} + const RoI1 c_roi1_3 := {3}; + const RoI1 c_roi1_4 := {5}; + + const integer c_int_25 := c_arrarr_1[c_roi1_3][c_roi1_4]; // 5 + + + testcase tc_const_array_indexing() runs on GeneralComp { + if (c_arr_1 == {1,2,3}) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_arr_2 == {4,5,6}) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_17 == 3) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_18 == 6) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_19 == 1) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_20 == 3) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_21 == 4) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_22 == 1) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_23 == 1) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_24 == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + if (c_int_25 == 5) { + setverdict(pass); + } else { + setverdict(fail); + } + } + + control { execute(tc_recordof_indexed_with_array()); execute(tc_recordof_indexed_with_recordof()); @@ -1683,6 +1949,10 @@ module IndexWithRecofArray { execute(tc_arrayfstr_indexed_with_recordof()); execute(tc_array_indexed_with_spec_array()); + + execute(tc_const_record_of_indexing()); + execute(tc_const_set_of_indexing()); + execute(tc_const_array_indexing()); } }