aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2021-05-17 19:20:56 +0200
committerTristan Gingold <tgingold@free.fr>2021-05-17 19:21:30 +0200
commitf07792aec9c4e943978f8212e2a0f6e870294dbf (patch)
tree4274269da8d798e97c5baec7416b72e35b8c147c /testsuite
parentf9cb7943690a49aff1fe48a5da46b41a77627ab7 (diff)
downloadghdl-f07792aec9c4e943978f8212e2a0f6e870294dbf.tar.gz
ghdl-f07792aec9c4e943978f8212e2a0f6e870294dbf.tar.bz2
ghdl-f07792aec9c4e943978f8212e2a0f6e870294dbf.zip
testsuite/gna: add a test for #1768
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/gna/issue1768/repro.vhdl25
-rw-r--r--testsuite/gna/issue1768/repro2.vhdl22
-rw-r--r--testsuite/gna/issue1768/repro3.vhdl12
-rwxr-xr-xtestsuite/gna/issue1768/testsuite.sh11
4 files changed, 70 insertions, 0 deletions
diff --git a/testsuite/gna/issue1768/repro.vhdl b/testsuite/gna/issue1768/repro.vhdl
new file mode 100644
index 000000000..2d2dda374
--- /dev/null
+++ b/testsuite/gna/issue1768/repro.vhdl
@@ -0,0 +1,25 @@
+package pkg is
+ function log2 (v : positive) return natural;
+end pkg;
+
+package body pkg is
+ function log2 (v : positive) return natural is
+ begin
+ return 2;
+ end log2;
+end pkg;
+
+use work.pkg.all;
+
+package repro is
+ constant W : natural := 8;
+ function f (vec : bit_vector(log2(W / 2) - 1 downto 0)) return bit;
+end repro;
+
+package body repro is
+ function f (vec : bit_vector(log2(W / 2) - 1 downto 0)) return bit is
+ begin
+ return '1';
+ end f;
+end repro;
+
diff --git a/testsuite/gna/issue1768/repro2.vhdl b/testsuite/gna/issue1768/repro2.vhdl
new file mode 100644
index 000000000..e2e9f15cc
--- /dev/null
+++ b/testsuite/gna/issue1768/repro2.vhdl
@@ -0,0 +1,22 @@
+package pkg2 is
+ type natural_array is array (positive range <>) of natural;
+ constant log2 : natural_array := (1 => 0,
+ 2 => 1,
+ 3 to 4 => 2,
+ 5 to 8 => 3);
+end pkg2;
+
+use work.pkg2.all;
+
+package repro2 is
+ constant W : natural := 8;
+ function f (vec : bit_vector(log2(W / 2) - 1 downto 0)) return bit;
+end repro2;
+
+package body repro2 is
+ function f (vec : bit_vector(log2(W / 2) - 1 downto 0)) return bit is
+ begin
+ return '1';
+ end f;
+end repro2;
+
diff --git a/testsuite/gna/issue1768/repro3.vhdl b/testsuite/gna/issue1768/repro3.vhdl
new file mode 100644
index 000000000..7c64f4c67
--- /dev/null
+++ b/testsuite/gna/issue1768/repro3.vhdl
@@ -0,0 +1,12 @@
+package repro3 is
+ constant bv : bit_vector := "1010011";
+ function f (vec : bit_vector := bv (0 to 3)) return bit;
+end repro3;
+
+package body repro3 is
+ function f (vec : bit_vector := bv (0 to 3)) return bit is
+ begin
+ return '1';
+ end f;
+end repro3;
+
diff --git a/testsuite/gna/issue1768/testsuite.sh b/testsuite/gna/issue1768/testsuite.sh
new file mode 100755
index 000000000..3ce439f6f
--- /dev/null
+++ b/testsuite/gna/issue1768/testsuite.sh
@@ -0,0 +1,11 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+analyze repro.vhdl
+analyze repro2.vhdl
+analyze repro3.vhdl
+
+clean
+
+echo "Test successful"