aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/gna
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-04-20 08:26:15 +0200
committerTristan Gingold <tgingold@free.fr>2020-04-20 12:19:49 +0200
commitff31302288cf477b8d4c7d353692f29872bc2789 (patch)
tree4aafc6b404a95693ce624c144b3716155d9e1c31 /testsuite/gna
parent5c1bfbbdd17fa628a1809520be3b1f276e18c02d (diff)
downloadghdl-ff31302288cf477b8d4c7d353692f29872bc2789.tar.gz
ghdl-ff31302288cf477b8d4c7d353692f29872bc2789.tar.bz2
ghdl-ff31302288cf477b8d4c7d353692f29872bc2789.zip
testsuite/gna: add a test for #1252
Diffstat (limited to 'testsuite/gna')
-rw-r--r--testsuite/gna/issue1252/caux.c2
-rw-r--r--testsuite/gna/issue1252/pkg.vhdl39
-rw-r--r--testsuite/gna/issue1252/tb.vhdl13
-rwxr-xr-xtestsuite/gna/issue1252/testsuite.sh10
4 files changed, 64 insertions, 0 deletions
diff --git a/testsuite/gna/issue1252/caux.c b/testsuite/gna/issue1252/caux.c
new file mode 100644
index 000000000..26bb300c8
--- /dev/null
+++ b/testsuite/gna/issue1252/caux.c
@@ -0,0 +1,2 @@
+int getInt(){return 1;};
+
diff --git a/testsuite/gna/issue1252/pkg.vhdl b/testsuite/gna/issue1252/pkg.vhdl
new file mode 100644
index 000000000..42a24fdc4
--- /dev/null
+++ b/testsuite/gna/issue1252/pkg.vhdl
@@ -0,0 +1,39 @@
+package pkg is
+ type c_int_prot is protected
+ impure function get return integer;
+ --------------------------------------------
+ impure function c_getInt return integer;
+ attribute foreign of c_getInt : function is "VHPIDIRECT getInt";
+ --------------------------------------------
+ end protected c_int_prot;
+ --------------------------------------------
+ -- impure function c_getInt return integer;
+ -- attribute foreign of c_getInt : function is "VHPIDIRECT getInt";
+ --------------------------------------------
+
+ shared variable c_int : c_int_prot;
+end package;
+
+package body pkg is
+ type c_int_prot is protected body
+ variable hidden_c_int : integer := c_getInt;
+
+ impure function get return integer is
+ begin
+ return hidden_c_int;
+ end function;
+
+ --------------------------------------------
+ impure function c_getInt return integer is
+ begin
+ assert false report "c_getInt VHPIDIRECT" severity failure;
+ end function;
+ --------------------------------------------
+ end protected body c_int_prot;
+ --------------------------------------------
+ -- impure function c_getInt return integer is
+ -- begin
+ -- assert false report "c_getInt VHPIDIRECT" severity failure;
+ -- end function;
+ --------------------------------------------
+end package body;
diff --git a/testsuite/gna/issue1252/tb.vhdl b/testsuite/gna/issue1252/tb.vhdl
new file mode 100644
index 000000000..89430c6c9
--- /dev/null
+++ b/testsuite/gna/issue1252/tb.vhdl
@@ -0,0 +1,13 @@
+use work.pkg.all;
+
+entity tb is
+end entity tb;
+
+architecture arch of tb is
+begin
+ process
+ begin
+ report integer'image(c_int.get);
+ wait;
+ end process;
+end arch ;
diff --git a/testsuite/gna/issue1252/testsuite.sh b/testsuite/gna/issue1252/testsuite.sh
new file mode 100755
index 000000000..7e0178e1c
--- /dev/null
+++ b/testsuite/gna/issue1252/testsuite.sh
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+export GHDL_STD_FLAGS=--std=02
+analyze pkg.vhdl
+
+clean
+
+echo "Test successful"