aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-03-08 08:05:59 +0100
committerTristan Gingold <tgingold@free.fr>2022-03-08 08:05:59 +0100
commit0ec2b140ac3ac7d0d754c6aaefe28c7c3cf11d28 (patch)
tree9ed05e55496d35ad670c520f55f27543d5988bad
parentc3af2b181bb1b68bfcf6190e03485189765161bc (diff)
downloadghdl-0ec2b140ac3ac7d0d754c6aaefe28c7c3cf11d28.tar.gz
ghdl-0ec2b140ac3ac7d0d754c6aaefe28c7c3cf11d28.tar.bz2
ghdl-0ec2b140ac3ac7d0d754c6aaefe28c7c3cf11d28.zip
testsuite/synth: add a test for #1993
-rw-r--r--testsuite/synth/issue1993/bug.vhdl59
-rw-r--r--testsuite/synth/issue1993/repro1.vhdl47
-rwxr-xr-xtestsuite/synth/issue1993/testsuite.sh9
3 files changed, 115 insertions, 0 deletions
diff --git a/testsuite/synth/issue1993/bug.vhdl b/testsuite/synth/issue1993/bug.vhdl
new file mode 100644
index 000000000..ab4eca231
--- /dev/null
+++ b/testsuite/synth/issue1993/bug.vhdl
@@ -0,0 +1,59 @@
+library IEEE;
+use IEEE.std_logic_1164.all;
+use IEEE.numeric_std.all;
+
+entity bug is
+ port (
+ clk : in std_ulogic
+ );
+end bug;
+
+architecture struct of bug is
+
+ type a_t is record
+ value : unsigned;
+ end record;
+
+ type a_array_t is array(natural range<>) of a_t;
+
+ type b_t is record
+ a : a_array_t;
+ end record;
+
+ type b_array_t is array(natural range<>) of b_t;
+
+ type table_t is array (natural range<>, natural range<>) of a_t;
+
+ function make_b return b_array_t is
+ variable ret : b_array_t(0 to 0)(a(0 to 31)(value(31 downto 0)));
+ begin
+ return ret;
+ end function;
+
+ function calculate_b return b_array_t is
+ function calculate_b(prefix : b_array_t; cur_value : natural) return b_array_t is
+ begin
+ if cur_value > 0 then
+ return prefix;
+ else
+ return calculate_b(prefix & make_b, cur_value + 1);
+ end if;
+ end function;
+
+ variable empty : b_array_t(0 to -1)(a(0 to 31)(value(31 downto 0)));
+ begin
+ return calculate_b(empty, 0);
+ end function;
+
+ function calculate_table(b : b_array_t) return table_t is
+ variable ret : table_t(0 to b'length-1, 0 to b(0).a'length-1)(value(31 downto 0));
+ begin
+ return ret;
+ end function;
+
+ constant b : b_array_t := calculate_b;
+ constant table : table_t := calculate_table(b);
+begin
+
+end architecture;
+
diff --git a/testsuite/synth/issue1993/repro1.vhdl b/testsuite/synth/issue1993/repro1.vhdl
new file mode 100644
index 000000000..9c6550f5e
--- /dev/null
+++ b/testsuite/synth/issue1993/repro1.vhdl
@@ -0,0 +1,47 @@
+entity bug is
+ port (
+ clk : in bit
+ );
+end bug;
+
+architecture struct of bug is
+
+ type a_t is record
+ value : bit_vector;
+ end record;
+
+ type a_array_t is array(natural range<>) of a_t;
+
+ type b_t is record
+ a : a_array_t;
+ end record;
+
+ type b_array_t is array(natural range<>) of b_t;
+
+ type table_t is array (natural range<>, natural range<>) of a_t;
+
+ function make_b return b_array_t is
+ variable ret : b_array_t(0 to 0)(a(0 to 31)(value(31 downto 0)));
+ begin
+ return ret;
+ end function;
+
+ function calculate_b return b_array_t
+ is
+ variable empty : b_array_t(0 to -1)(a(0 to 31)(value(31 downto 0)));
+ begin
+ return empty & make_b;
+ end function;
+
+ function calculate_table(b : b_array_t) return table_t is
+ variable ret : table_t(0 to b'length-1, 0 to b(0).a'length-1)(value(31 downto 0));
+ begin
+ return ret;
+ end function;
+
+ constant b : b_array_t := calculate_b;
+ constant table : table_t := calculate_table(b);
+begin
+
+end architecture;
+
diff --git a/testsuite/synth/issue1993/testsuite.sh b/testsuite/synth/issue1993/testsuite.sh
new file mode 100755
index 000000000..bb55be7f0
--- /dev/null
+++ b/testsuite/synth/issue1993/testsuite.sh
@@ -0,0 +1,9 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+GHDL_STD_FLAGS=--std=08
+synth_only repro1
+synth_only bug
+
+echo "Test successful"