aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--testsuite/gna/issue1229/aux.c1
-rw-r--r--testsuite/gna/issue1229/pkg.vhdl20
-rw-r--r--testsuite/gna/issue1229/tb.vhdl17
-rwxr-xr-xtestsuite/gna/issue1229/testsuite.sh15
4 files changed, 53 insertions, 0 deletions
diff --git a/testsuite/gna/issue1229/aux.c b/testsuite/gna/issue1229/aux.c
new file mode 100644
index 000000000..f355dea13
--- /dev/null
+++ b/testsuite/gna/issue1229/aux.c
@@ -0,0 +1 @@
+int getInt(){return 141;}
diff --git a/testsuite/gna/issue1229/pkg.vhdl b/testsuite/gna/issue1229/pkg.vhdl
new file mode 100644
index 000000000..660b00a58
--- /dev/null
+++ b/testsuite/gna/issue1229/pkg.vhdl
@@ -0,0 +1,20 @@
+package pkg is
+ generic (N : integer := 2);
+
+ procedure showPackageN;
+
+ impure function c_int return integer;
+ attribute foreign of c_int : function is "VHPIDIRECT aux.so getInt";
+end package pkg;
+
+package body pkg is
+ procedure showPackageN is
+ begin
+ report integer'image(N);
+ end;
+
+ impure function c_int return integer is
+ begin
+ assert false report "c_int VHPI" severity failure;
+ end c_int;
+end package body pkg;
diff --git a/testsuite/gna/issue1229/tb.vhdl b/testsuite/gna/issue1229/tb.vhdl
new file mode 100644
index 000000000..efe510017
--- /dev/null
+++ b/testsuite/gna/issue1229/tb.vhdl
@@ -0,0 +1,17 @@
+entity tb is
+end entity tb;
+
+architecture RTL of tb is
+ package tbpkg is new work.pkg generic map (N => 3);
+begin
+ process
+ use tbpkg.all;
+ variable int : integer := c_int;
+ begin
+ report tbpkg.c_int'foreign;
+
+ showPackageN;
+ report "C Int: " & integer'image(int);
+ wait;
+ end process;
+end architecture RTL;
diff --git a/testsuite/gna/issue1229/testsuite.sh b/testsuite/gna/issue1229/testsuite.sh
new file mode 100755
index 000000000..67082607b
--- /dev/null
+++ b/testsuite/gna/issue1229/testsuite.sh
@@ -0,0 +1,15 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+gcc -c -fPIC aux.c
+gcc -shared -o aux.so aux.o
+
+export GHDL_STD_FLAGS=--std=08
+analyze pkg.vhdl tb.vhdl
+elab_simulate tb
+
+clean
+rm -f aux.o aux.so
+
+echo "Test successful"