diff --git a/compiler2/Type_chk.cc b/compiler2/Type_chk.cc index 660e5b381726306a4e951d4c755254c45ad37551..d462a299f5908be9b2539af691cff1705315803e 100644 --- a/compiler2/Type_chk.cc +++ b/compiler2/Type_chk.cc @@ -4196,7 +4196,14 @@ bool Type::chk_this_refd_value(Value *value, Common::Assignment *lhs, expected_v value->set_valuetype(Value::V_ERROR); return self_ref; case Assignment::A_CONST: - is_const = true; + if (expected_value == EXPECTED_CONSTANT && + ass->get_Value()->is_unfoldable(NULL, expected_value)) { + value->error("Referenced constant value cannot be evaluated at compile-time"); + error_flag = true; + } + else { + is_const = true; + } break; case Assignment::A_OBJECT: case Assignment::A_OS: { diff --git a/function_test/Semantic_Analyser/Makefile.semantic b/function_test/Semantic_Analyser/Makefile.semantic index 5f01b46a0603c310c980f1fdb3112d0934149240..869444f0da27433b63c46dbf1aa5f974ea434586 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 oop defaultAlternative +json realtime map_param oop defaultAlternative issues ifdef RT2 SADIRS += deprecated erroneous_attributes template_concat endif diff --git a/function_test/Semantic_Analyser/issues/.gitignore b/function_test/Semantic_Analyser/issues/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2d293255e6d2f314e34950e486a48630d873491 --- /dev/null +++ b/function_test/Semantic_Analyser/issues/.gitignore @@ -0,0 +1,2 @@ +!Makefile +!*.ttcn diff --git a/function_test/Semantic_Analyser/issues/Issue495_SE.ttcn b/function_test/Semantic_Analyser/issues/Issue495_SE.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..17d4b671c7a22e7c3ed651cd11f2d0b87db30de1 --- /dev/null +++ b/function_test/Semantic_Analyser/issues/Issue495_SE.ttcn @@ -0,0 +1,37 @@ +/****************************************************************************** + * Copyright (c) 2000-2021 Ericsson Telecom AB + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html + * + * Contributors: + * Baranyi, Botond + * + ******************************************************************************/ + +module Issue495 //^In TTCN-3 module// +{ + +modulepar +{ + integer tsp_cl_num := 10; +} + + +type component MTC_CT {}; + + + testcase tc_Fatal_Error() runs on MTC_CT //^In testcase definition// + { + const integer cl_num0 := 10; + var integer Int0[cl_num0]; + + const integer cl_num := tsp_cl_num; + var integer Int[cl_num]; //^In variable definition// //^In array size// //Referenced constant value cannot be evaluated at compile-time// + + var integer Int2[tsp_cl_num]; //^In variable definition// //^In array size// //Reference to an \(evaluable\) constant value was expected instead of module parameter// + + } + +} diff --git a/function_test/Semantic_Analyser/issues/Makefile b/function_test/Semantic_Analyser/issues/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..7abfd0db959ee0ca5b7701f2f2b2f334e1680228 --- /dev/null +++ b/function_test/Semantic_Analyser/issues/Makefile @@ -0,0 +1,12 @@ +############################################################################## +# Copyright (c) 2000-2021 Ericsson Telecom AB +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v2.0 +# which accompanies this distribution, and is available at +# https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html +# +# Contributors: +# Baranyi, Botond +# +############################################################################## +include ../common.mk diff --git a/function_test/Semantic_Analyser/issues/t b/function_test/Semantic_Analyser/issues/t new file mode 100755 index 0000000000000000000000000000000000000000..3a4b58ec16cf2f1390a36c7a92f8823e3b94b425 --- /dev/null +++ b/function_test/Semantic_Analyser/issues/t @@ -0,0 +1,9 @@ +#!/usr/bin/perl +# note this is called through "perl -w" +use strict; + +my $self = $0; +$self =~ s!/t!!; + +exec('make check --no-print-directory -s -C ' . $self); +