From a76a041d967d05a3b59da7c454a8cbbe2c802989 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Sun, 21 Nov 2021 08:21:24 +0100 Subject: testsuite/synth: add a test for #1920 --- testsuite/synth/issue1920/ent1.vhdl | 30 ++++++++++++++++++++++++++++++ testsuite/synth/issue1920/ent2.vhdl | 30 ++++++++++++++++++++++++++++++ testsuite/synth/issue1920/testsuite.sh | 8 ++++++++ 3 files changed, 68 insertions(+) create mode 100644 testsuite/synth/issue1920/ent1.vhdl create mode 100644 testsuite/synth/issue1920/ent2.vhdl create mode 100755 testsuite/synth/issue1920/testsuite.sh (limited to 'testsuite') diff --git a/testsuite/synth/issue1920/ent1.vhdl b/testsuite/synth/issue1920/ent1.vhdl new file mode 100644 index 000000000..f6e3cf0c9 --- /dev/null +++ b/testsuite/synth/issue1920/ent1.vhdl @@ -0,0 +1,30 @@ +library ieee; +use ieee.std_logic_1164.all; + +entity ent is + port ( + inputs : in std_logic; + result : out std_logic + ); +end entity; + +architecture synth of ent is + + function local_func(A : std_logic) return std_logic is + begin + return A; + end function; + + -- With this line + -- As expected, GHDL emits a good enough error message: cannot use signal value during elaboration + --constant C : std_logic := inputs; + + -- But with this line, which is erroneous code, because a constant cannot be computed from a non-constant + -- GHDL crashes with an assertion: raised CONSTRAINT_ERROR : netlists-builders.adb:791 access check failed + constant C : std_logic := local_func(inputs); + +begin + + result <= C; + +end architecture; diff --git a/testsuite/synth/issue1920/ent2.vhdl b/testsuite/synth/issue1920/ent2.vhdl new file mode 100644 index 000000000..f524c0469 --- /dev/null +++ b/testsuite/synth/issue1920/ent2.vhdl @@ -0,0 +1,30 @@ +library ieee; +use ieee.std_logic_1164.all; + +entity ent is + port ( + inputs : in std_logic; + result : out std_logic + ); +end entity; + +architecture synth of ent is + + function local_func(A : std_logic) return std_logic is + begin + return A; + end function; + + -- With this line + -- As expected, GHDL emits a good enough error message: cannot use signal value during elaboration + constant C : std_logic := inputs; + + -- But with this line, which is erroneous code, because a constant cannot be computed from a non-constant + -- GHDL crashes with an assertion: raised CONSTRAINT_ERROR : netlists-builders.adb:791 access check failed + --constant C : std_logic := local_func(inputs); + +begin + + result <= C; + +end architecture; diff --git a/testsuite/synth/issue1920/testsuite.sh b/testsuite/synth/issue1920/testsuite.sh new file mode 100755 index 000000000..81da7c94f --- /dev/null +++ b/testsuite/synth/issue1920/testsuite.sh @@ -0,0 +1,8 @@ +#! /bin/sh + +. ../../testenv.sh + +synth_failure ent1.vhdl -e +synth_failure ent2.vhdl -e + +echo "Test successful" -- cgit v1.2.3