diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-06-25 18:41:05 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-06-25 18:41:05 +0200 |
commit | 71bafde697314d92bf73f9bccc14e49550260bf1 (patch) | |
tree | e7bc7077bc984163f76d1bc734822cc7322e9d32 /testsuite/gna/issue1381 | |
parent | e49f709cab51d8f1d0b4a11f93ed383dce8392ec (diff) | |
download | ghdl-71bafde697314d92bf73f9bccc14e49550260bf1.tar.gz ghdl-71bafde697314d92bf73f9bccc14e49550260bf1.tar.bz2 ghdl-71bafde697314d92bf73f9bccc14e49550260bf1.zip |
testsuite/gna: add tests for #1381
Diffstat (limited to 'testsuite/gna/issue1381')
-rw-r--r-- | testsuite/gna/issue1381/repro.vhdl | 21 | ||||
-rw-r--r-- | testsuite/gna/issue1381/repro2.vhdl | 28 | ||||
-rw-r--r-- | testsuite/gna/issue1381/repro3.vhdl | 14 | ||||
-rw-r--r-- | testsuite/gna/issue1381/repro4.vhdl | 14 | ||||
-rwxr-xr-x | testsuite/gna/issue1381/testsuite.sh | 12 |
5 files changed, 89 insertions, 0 deletions
diff --git a/testsuite/gna/issue1381/repro.vhdl b/testsuite/gna/issue1381/repro.vhdl new file mode 100644 index 000000000..af3c550fa --- /dev/null +++ b/testsuite/gna/issue1381/repro.vhdl @@ -0,0 +1,21 @@ +entity repro is +end; + +architecture behav of repro is + type id_arr is array(bit) of bit; + + constant idc : id_arr := ('0' => '0', '1' => '1'); + + function f(a : bit_vector) return bit_vector + is + variable v : bit_vector(1 to a'length) := a; + variable r : bit_vector(1 to a'length); + begin + for i in v'range loop + r(i) := idc(v (i)); + end loop; + return r; + end f; +begin + assert f("01") = "01"; +end behav; diff --git a/testsuite/gna/issue1381/repro2.vhdl b/testsuite/gna/issue1381/repro2.vhdl new file mode 100644 index 000000000..a3347df3f --- /dev/null +++ b/testsuite/gna/issue1381/repro2.vhdl @@ -0,0 +1,28 @@ +entity repro2 is + port (o : out bit); +end; + +architecture behav of repro2 is + function idf (a : bit) return bit is + begin + return a; + end idf; + + type id_arr is array(bit) of bit; + + constant idc : id_arr := ('0' => '0', '1' => '1'); + + function f(a : bit_vector) return bit_vector + is + variable v : bit_vector(1 to a'length) := a; + variable r : bit_vector(1 to a'length); + begin + for i in v'range loop + r(i) := idc(v (i)); + end loop; + return r; + end f; +begin + assert f("01") = "01"; + assert idc(o) = '1'; +end behav; diff --git a/testsuite/gna/issue1381/repro3.vhdl b/testsuite/gna/issue1381/repro3.vhdl new file mode 100644 index 000000000..4ff3449ff --- /dev/null +++ b/testsuite/gna/issue1381/repro3.vhdl @@ -0,0 +1,14 @@ +entity repro3 is + port (n : out natural); +end; + +architecture behav of repro3 is + impure function f(a : bit_vector) return bit_vector + is + subtype st is natural range 1 to n; + begin + return a; + end f; +begin + assert f("01") = "01"; +end behav; diff --git a/testsuite/gna/issue1381/repro4.vhdl b/testsuite/gna/issue1381/repro4.vhdl new file mode 100644 index 000000000..9a54e4027 --- /dev/null +++ b/testsuite/gna/issue1381/repro4.vhdl @@ -0,0 +1,14 @@ +entity repro4 is +end; + +architecture behav of repro4 is + impure function f(a : bit_vector) return bit_vector + is + variable n : natural := 2; + subtype st is natural range 1 to n; + begin + return a; + end f; +begin + assert f("01") = "01"; +end behav; diff --git a/testsuite/gna/issue1381/testsuite.sh b/testsuite/gna/issue1381/testsuite.sh new file mode 100755 index 000000000..10388ef94 --- /dev/null +++ b/testsuite/gna/issue1381/testsuite.sh @@ -0,0 +1,12 @@ +#! /bin/sh + +. ../../testenv.sh + +analyze -Wunused -Werror repro.vhdl +analyze_failure repro2.vhdl +analyze_failure repro3.vhdl +analyze -Wunused -Werror repro4.vhdl + +clean + +echo "Test successful" |