From 9c6156c842056591258386bd7de192b5f600b3af Mon Sep 17 00:00:00 2001
From: Botond Baranyi <botond.baranyi@ericsson.com>
Date: Mon, 7 Jun 2021 18:20:33 +0200
Subject: [PATCH] Fixed fatal error caused by using a constant initialized with
 a module parameter as array dimensions (issue #495)

Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com>
---
 compiler2/Type_chk.cc                             | 9 ++++++++-
 function_test/Semantic_Analyser/Makefile.semantic | 2 +-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/compiler2/Type_chk.cc b/compiler2/Type_chk.cc
index 660e5b381..d462a299f 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 5f01b46a0..869444f0d 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
-- 
GitLab