aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-07-28 18:33:16 +0200
committerTristan Gingold <tgingold@free.fr>2022-07-28 18:33:16 +0200
commita961af98bbadc6e3490110e11531d36fe7927b09 (patch)
tree302956f599ed90b2e07935e826d4559fb6a6d54d
parenta6bccff01ac66453be5914df80efc1d7271df678 (diff)
downloadghdl-a961af98bbadc6e3490110e11531d36fe7927b09.tar.gz
ghdl-a961af98bbadc6e3490110e11531d36fe7927b09.tar.bz2
ghdl-a961af98bbadc6e3490110e11531d36fe7927b09.zip
testsuite/gna: add tests for #2148
-rw-r--r--testsuite/gna/issue2148/e.vhdl35
-rw-r--r--testsuite/gna/issue2148/e1.vhdl12
-rw-r--r--testsuite/gna/issue2148/e2.vhdl12
-rwxr-xr-xtestsuite/gna/issue2148/testsuite.sh15
-rw-r--r--testsuite/gna/issue2148/unused.vhdl16
5 files changed, 90 insertions, 0 deletions
diff --git a/testsuite/gna/issue2148/e.vhdl b/testsuite/gna/issue2148/e.vhdl
new file mode 100644
index 000000000..52fd61067
--- /dev/null
+++ b/testsuite/gna/issue2148/e.vhdl
@@ -0,0 +1,35 @@
+entity e is end;
+
+architecture a of e is
+
+ --------------------------------------------------------------------------------
+ -- Variable is reported as unused, but it is used for its 'image attribute
+ --------------------------------------------------------------------------------
+ procedure p is
+ variable a : integer;
+ begin
+ report integer'image(a);
+ end;
+
+
+ --------------------------------------------------------------------------------
+ -- Variable b is reported as unused, but it is the return value of function f.
+ --------------------------------------------------------------------------------
+ type integer_vector_93 is array (natural range <>) of integer;
+ function f return integer_vector_93 is
+ variable b : integer;
+ begin
+ return (0 => b);
+ end;
+begin
+
+
+ -- This code can be ignored. It is only to suppress non-spurious warnings
+ -- about subprograms p and f being unused
+ process
+ constant c : integer_vector_93 := f;
+ begin
+ p;
+ wait;
+ end process;
+end;
diff --git a/testsuite/gna/issue2148/e1.vhdl b/testsuite/gna/issue2148/e1.vhdl
new file mode 100644
index 000000000..7a366f68f
--- /dev/null
+++ b/testsuite/gna/issue2148/e1.vhdl
@@ -0,0 +1,12 @@
+entity e1 is
+ port (v : out natural);
+end;
+
+architecture behav of e1 is
+begin
+ process
+ begin
+ report natural'image(v);
+ wait;
+ end process;
+end;
diff --git a/testsuite/gna/issue2148/e2.vhdl b/testsuite/gna/issue2148/e2.vhdl
new file mode 100644
index 000000000..887d77841
--- /dev/null
+++ b/testsuite/gna/issue2148/e2.vhdl
@@ -0,0 +1,12 @@
+entity e2 is
+ port (v : out natural);
+end;
+
+architecture behav of e2 is
+begin
+ process
+ begin
+ report (1 to v => 'X');
+ wait;
+ end process;
+end;
diff --git a/testsuite/gna/issue2148/testsuite.sh b/testsuite/gna/issue2148/testsuite.sh
new file mode 100755
index 000000000..3253990f9
--- /dev/null
+++ b/testsuite/gna/issue2148/testsuite.sh
@@ -0,0 +1,15 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+export GHDL_STD_FLAGS=-Werror=unused
+analyze_failure unused.vhdl
+analyze e.vhdl
+
+unset GHDL_STD_FLAGS
+analyze_failure e1.vhdl
+analyze_failure e2.vhdl
+
+clean
+
+echo "Test successful"
diff --git a/testsuite/gna/issue2148/unused.vhdl b/testsuite/gna/issue2148/unused.vhdl
new file mode 100644
index 000000000..03860f23f
--- /dev/null
+++ b/testsuite/gna/issue2148/unused.vhdl
@@ -0,0 +1,16 @@
+entity e is end;
+
+architecture a of e is
+
+ procedure p is
+ variable a : integer;
+ begin
+ null;
+ end;
+begin
+ process
+ begin
+ p;
+ wait;
+ end process;
+end;