From 304868c00803062cab662d308def9f091305f081 Mon Sep 17 00:00:00 2001
From: Tristan Gingold <tgingold@free.fr>
Date: Sat, 18 Apr 2020 08:04:13 +0200
Subject: testsuite/gna: add a test from #1240

---
 testsuite/gna/issue1240/issue1.vhdl  | 12 ++++++++++++
 testsuite/gna/issue1240/issue2.vhdl  | 13 +++++++++++++
 testsuite/gna/issue1240/testsuite.sh | 12 ++++++++++++
 3 files changed, 37 insertions(+)
 create mode 100644 testsuite/gna/issue1240/issue1.vhdl
 create mode 100644 testsuite/gna/issue1240/issue2.vhdl
 create mode 100755 testsuite/gna/issue1240/testsuite.sh

diff --git a/testsuite/gna/issue1240/issue1.vhdl b/testsuite/gna/issue1240/issue1.vhdl
new file mode 100644
index 000000000..cc5bf9f46
--- /dev/null
+++ b/testsuite/gna/issue1240/issue1.vhdl
@@ -0,0 +1,12 @@
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+entity issue1 is
+    port (foobar : out signed (3 downto 0));
+end issue1;
+
+architecture beh of issue1 is
+begin
+    foobar <= to_signed(natural'(-1), foobar'length);
+end architecture;
diff --git a/testsuite/gna/issue1240/issue2.vhdl b/testsuite/gna/issue1240/issue2.vhdl
new file mode 100644
index 000000000..7e9f9032a
--- /dev/null
+++ b/testsuite/gna/issue1240/issue2.vhdl
@@ -0,0 +1,13 @@
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+entity issue2 is
+    port (foobar : out signed (3 downto 0));
+end issue2;
+
+architecture beh of issue2 is
+    subtype my_type is natural range 0 to 1; -- width = 1
+begin
+    foobar <= to_signed(my_type'(-15), foobar'length);
+end architecture;
diff --git a/testsuite/gna/issue1240/testsuite.sh b/testsuite/gna/issue1240/testsuite.sh
new file mode 100755
index 000000000..602389099
--- /dev/null
+++ b/testsuite/gna/issue1240/testsuite.sh
@@ -0,0 +1,12 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+export GHDL_STD_FLAGS=-Werror=runtime-error
+
+analyze_failure issue1.vhdl
+analyze_failure issue2.vhdl
+
+clean
+
+echo "Test successful"
-- 
cgit v1.2.3