aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-12-10 21:52:48 +0100
committerTristan Gingold <tgingold@free.fr>2022-12-10 21:52:48 +0100
commit3c23c984d2e75e1a455a68e7be1656948c42ef75 (patch)
tree3553df674742158a8a4ec2843736ea57f04b9f6b
parent1816aea7669e10dc68a7f20d7956e40b727d87b8 (diff)
downloadghdl-3c23c984d2e75e1a455a68e7be1656948c42ef75.tar.gz
ghdl-3c23c984d2e75e1a455a68e7be1656948c42ef75.tar.bz2
ghdl-3c23c984d2e75e1a455a68e7be1656948c42ef75.zip
testsuite/gna: add a test for #2216
-rw-r--r--testsuite/gna/issue2216/ent.vhdl9
-rw-r--r--testsuite/gna/issue2216/pkg.vhdl41
-rwxr-xr-xtestsuite/gna/issue2216/testsuite.sh11
3 files changed, 61 insertions, 0 deletions
diff --git a/testsuite/gna/issue2216/ent.vhdl b/testsuite/gna/issue2216/ent.vhdl
new file mode 100644
index 000000000..c551f5bdd
--- /dev/null
+++ b/testsuite/gna/issue2216/ent.vhdl
@@ -0,0 +1,9 @@
+use work.MemorySupportPkg.all;
+
+entity ent is
+end;
+
+architecture behav of ent is
+ constant c : MemBlockType := InitMemoryBaseType_X (3, 2);
+begin
+end;
diff --git a/testsuite/gna/issue2216/pkg.vhdl b/testsuite/gna/issue2216/pkg.vhdl
new file mode 100644
index 000000000..4dedf8bb4
--- /dev/null
+++ b/testsuite/gna/issue2216/pkg.vhdl
@@ -0,0 +1,41 @@
+package MemorySupportPkg is
+
+ subtype MemoryBaseType is integer_vector ;
+ type MemBlockType is array (integer range <>) of MemoryBaseType ;
+
+ function InitMemoryBaseType_X(BlockWidth, BaseWidth : integer) return MemBlockType ;
+
+end MemorySupportPkg ;
+
+package body MemorySupportPkg is
+
+
+-- Works
+-- ------------------------------------------------------------
+-- function InitMemoryBaseType_X(BlockWidth, BaseWidth : integer) return MemBlockType is
+-- ------------------------------------------------------------
+-- constant BaseU : MemoryBaseType(0 to BaseWidth-1) := (others => -1) ;
+-- begin
+-- return MemBlockType'(0 to 2**BlockWidth-1 => BaseU) ;
+-- end function InitMemoryBaseType_X ;
+
+-- Fails
+ ------------------------------------------------------------
+ function InitMemoryBaseType_X(BlockWidth, BaseWidth : integer) return MemBlockType is
+ ------------------------------------------------------------
+ constant BaseU : MemoryBaseType := (0 to BaseWidth-1 => -1) ;
+ begin
+ return MemBlockType'(0 to 2**BlockWidth-1 => BaseU) ;
+ end function InitMemoryBaseType_X ;
+
+-- Fails
+-- ------------------------------------------------------------
+-- function InitMemoryBaseType_X(BlockWidth, BaseWidth : integer) return MemBlockType is
+-- ------------------------------------------------------------
+-- constant BaseU : MemoryBaseType(0 to BaseWidth-1) := (others => -1) ;
+-- constant BlockWidthU : MemBlockType(0 to 2**BlockWidth-1) := (others => BaseU) ;
+-- -- --!! Also Fails constant BlockWidthU : MemBlockType := (0 to 2**BlockWidth-1 => BaseU) ;
+-- begin
+-- return BlockWidthU ;
+-- end function InitMemoryBaseType_X ;
+end MemorySupportPkg ;
diff --git a/testsuite/gna/issue2216/testsuite.sh b/testsuite/gna/issue2216/testsuite.sh
new file mode 100755
index 000000000..331a801f8
--- /dev/null
+++ b/testsuite/gna/issue2216/testsuite.sh
@@ -0,0 +1,11 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+export GHDL_STD_FLAGS=--std=08
+analyze pkg.vhdl ent.vhdl
+elab_simulate ent
+
+clean
+
+echo "Test successful"