aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-08-07 07:11:51 +0200
committerTristan Gingold <tgingold@free.fr>2022-08-07 10:00:12 +0200
commit63c97602af5a19a6e3e48c6c1cafb98f0bb9359d (patch)
treee1dc08e6919eba30e3dedc803edb43d71519624c /testsuite
parent5c8b50f69d70f4e2d0a9910a7914245d0796b758 (diff)
downloadghdl-63c97602af5a19a6e3e48c6c1cafb98f0bb9359d.tar.gz
ghdl-63c97602af5a19a6e3e48c6c1cafb98f0bb9359d.tar.bz2
ghdl-63c97602af5a19a6e3e48c6c1cafb98f0bb9359d.zip
testsuite/gna: add a reproducer for #2163
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/gna/issue2163/memory_pkg.vhdl12
-rw-r--r--testsuite/gna/issue2163/pkg1.vhdl30
-rw-r--r--testsuite/gna/issue2163/pkg2.vhdl27
-rw-r--r--testsuite/gna/issue2163/pkg3.vhdl31
-rwxr-xr-xtestsuite/gna/issue2163/testsuite.sh16
5 files changed, 116 insertions, 0 deletions
diff --git a/testsuite/gna/issue2163/memory_pkg.vhdl b/testsuite/gna/issue2163/memory_pkg.vhdl
new file mode 100644
index 000000000..952999770
--- /dev/null
+++ b/testsuite/gna/issue2163/memory_pkg.vhdl
@@ -0,0 +1,12 @@
+library ieee;
+use ieee.std_logic_1164.all;
+
+package MemoryGenericPkg is
+ generic (
+ type MemoryBaseType ;
+ function ToMemoryBaseType(A : std_logic_vector) return MemoryBaseType is <> ;
+ function FromMemoryBaseType(A : MemoryBaseType ; Size : integer) return std_logic_vector is <> ;
+ function InitMemoryBaseType(Size : integer) return MemoryBaseType is <>
+ ) ;
+-- Stuff
+end package MemoryGenericPkg ;
diff --git a/testsuite/gna/issue2163/pkg1.vhdl b/testsuite/gna/issue2163/pkg1.vhdl
new file mode 100644
index 000000000..b6737a7d4
--- /dev/null
+++ b/testsuite/gna/issue2163/pkg1.vhdl
@@ -0,0 +1,30 @@
+package pkg1 is
+ generic (
+ type atyp;
+ function plus (a: atyp) return natural is <>);
+ function wrap (a : atyp) return natural;
+end pkg1;
+
+package body pkg1 is
+ function wrap (a : atyp) return natural is
+ begin
+ return plus (a);
+ end wrap;
+end pkg1;
+
+
+entity tb_pkg1 is
+end;
+
+architecture behav of tb_pkg1 is
+ function plus (a: bit_vector) return natural is
+ begin
+ return a'length;
+ end plus;
+
+ package my_pkg1 is new work.pkg1 generic map (atyp => bit_vector);
+
+ constant c : natural := my_pkg1.wrap("0101");
+begin
+ assert c = 4 severity failure;
+end behav;
diff --git a/testsuite/gna/issue2163/pkg2.vhdl b/testsuite/gna/issue2163/pkg2.vhdl
new file mode 100644
index 000000000..232419e06
--- /dev/null
+++ b/testsuite/gna/issue2163/pkg2.vhdl
@@ -0,0 +1,27 @@
+package pkg2 is
+ generic (
+ type atyp;
+ function plus (a: atyp) return natural is <>);
+ function wrap (a : atyp) return natural;
+end pkg2;
+
+package body pkg2 is
+ function wrap (a : atyp) return natural is
+ begin
+ return plus (a);
+ end wrap;
+end pkg2;
+
+
+entity tb_pkg2 is
+end;
+
+architecture behav of tb_pkg2 is
+ constant plus : natural := 5;
+ package my_pkg2 is new work.pkg2
+ generic map (atyp => bit_vector, plus => plus);
+
+ constant c : natural := my_pkg2.wrap("0101");
+begin
+ assert c = 4 severity failure;
+end behav;
diff --git a/testsuite/gna/issue2163/pkg3.vhdl b/testsuite/gna/issue2163/pkg3.vhdl
new file mode 100644
index 000000000..724488def
--- /dev/null
+++ b/testsuite/gna/issue2163/pkg3.vhdl
@@ -0,0 +1,31 @@
+package pkg3 is
+ generic (
+ type atyp;
+ function plus (a: atyp) return natural is <>);
+ function wrap (a : atyp) return natural;
+end pkg3;
+
+package body pkg3 is
+ function wrap (a : atyp) return natural is
+ begin
+ return plus (a);
+ end wrap;
+end pkg3;
+
+
+entity tb_pkg3 is
+end;
+
+architecture behav of tb_pkg3 is
+ function plus (a: bit_vector) return natural is
+ begin
+ return a'length;
+ end plus;
+
+ package my_pkg3 is new work.pkg3 generic map (atyp => bit_vector,
+ plus => open);
+
+ constant c : natural := my_pkg3.wrap("0101");
+begin
+ assert c = 4 severity failure;
+end behav;
diff --git a/testsuite/gna/issue2163/testsuite.sh b/testsuite/gna/issue2163/testsuite.sh
new file mode 100755
index 000000000..34140d8c2
--- /dev/null
+++ b/testsuite/gna/issue2163/testsuite.sh
@@ -0,0 +1,16 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+export GHDL_STD_FLAGS=--std=08
+analyze_failure pkg2.vhdl
+
+analyze pkg1.vhdl
+elab_simulate tb_pkg1
+
+analyze pkg3.vhdl
+elab_simulate tb_pkg3
+
+clean
+
+echo "Test successful"