aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2014-01-01 07:18:58 +0100
committerTristan Gingold <tgingold@free.fr>2014-01-01 07:18:58 +0100
commit237fd4c864c50a8b0ab99daf198ad60790cb6d0f (patch)
tree315bb7ed4bde66b1f0dea79a5fce454b0adce2f1
parent8f92f5f35a740182637d137b934b539a7a469014 (diff)
downloadghdl-237fd4c864c50a8b0ab99daf198ad60790cb6d0f.tar.gz
ghdl-237fd4c864c50a8b0ab99daf198ad60790cb6d0f.tar.bz2
ghdl-237fd4c864c50a8b0ab99daf198ad60790cb6d0f.zip
Fix bug18280, and add it.
-rw-r--r--sem_specs.adb18
-rw-r--r--testsuite/gna/bug18280/alias_bug.txt33
-rw-r--r--testsuite/gna/bug18280/alias_bug.vhd41
-rw-r--r--testsuite/gna/bug18280/ghdc.bat2
-rwxr-xr-xtestsuite/gna/bug18280/testsuite.sh10
5 files changed, 97 insertions, 7 deletions
diff --git a/sem_specs.adb b/sem_specs.adb
index 885a41abc..11a3711bd 100644
--- a/sem_specs.adb
+++ b/sem_specs.adb
@@ -331,7 +331,9 @@ package body Sem_Specs is
is
Res : Boolean;
- procedure Sem_Named_Entity1 (Ent : Iir; Decl : Iir)
+ -- If declaration DECL matches then named entity ENT, apply attribute
+ -- specification and returns TRUE. Otherwise, return FALSE.
+ function Sem_Named_Entity1 (Ent : Iir; Decl : Iir) return Boolean
is
Ent_Id : Name_Id;
begin
@@ -345,9 +347,10 @@ package body Sem_Specs is
else
Attribute_A_Decl
(Decl, Attr, Name, Is_Designators, Check_Defined);
- Res := True;
+ return True;
end if;
end if;
+ return False;
end Sem_Named_Entity1;
procedure Sem_Named_Entity (Ent : Iir) is
@@ -366,7 +369,7 @@ package body Sem_Specs is
| Iir_Kind_Unit_Declaration
| Iir_Kind_Group_Template_Declaration
| Iir_Kind_Group_Declaration =>
- Sem_Named_Entity1 (Ent, Ent);
+ Res := Res or Sem_Named_Entity1 (Ent, Ent);
when Iir_Kind_Object_Alias_Declaration =>
-- LRM93 5.1
-- An entity designator that denotes an alias of an object is
@@ -374,18 +377,19 @@ package body Sem_Specs is
-- or slice thereof.
declare
Decl : Iir;
+ Applied : Boolean;
begin
Decl := Get_Name (Ent);
- if Get_Base_Name (Decl) /= Decl then
+ Applied := Sem_Named_Entity1 (Ent, Decl);
+ if Applied and then Get_Base_Name (Decl) /= Decl then
Error_Msg_Sem
(Disp_Node (Ent) & " does not denote the entire object",
Attr);
- return;
end if;
- Sem_Named_Entity1 (Ent, Decl);
+ Res := Res or Applied;
end;
when Iir_Kind_Non_Object_Alias_Declaration =>
- Sem_Named_Entity1 (Ent, Get_Name (Ent));
+ Res := Res or Sem_Named_Entity1 (Ent, Get_Name (Ent));
when Iir_Kind_Attribute_Declaration
| Iir_Kind_Attribute_Specification
| Iir_Kind_Configuration_Specification
diff --git a/testsuite/gna/bug18280/alias_bug.txt b/testsuite/gna/bug18280/alias_bug.txt
new file mode 100644
index 000000000..b86e47d8b
--- /dev/null
+++ b/testsuite/gna/bug18280/alias_bug.txt
@@ -0,0 +1,33 @@
+
+ The Windows 0.29.1 GHDL build errors at compile time when
+an attribute is placed on a signal for which an alias has
+previously been created.
+
+--------
+
+Code snippet from attached <alias_bug.vhd> example:
+
+ signal processor_address : std_logic_vector(15 downto 0);
+
+ alias address_ms : std_logic_vector(3 downto 0) is processor_address(15 downto 12);
+
+ attribute keep : boolean;
+ attribute keep of processor_address: signal is TRUE;
+
+Resulting error message:
+
+ .\alias_bug.vhd:35:13: alias "address_ms" does not denote the entire object
+
+--------
+
+Workaround:
+
+ Moving the alias _after_ the attribute causes the error to go away.
+
+--------
+
+alias_bug.zip contents :
+
+ alias_bug.txt this file
+ alias_bug.vhd test program to demonstrate alias bug
+ ghdc.bat batch file to invoke compiler
diff --git a/testsuite/gna/bug18280/alias_bug.vhd b/testsuite/gna/bug18280/alias_bug.vhd
new file mode 100644
index 000000000..c9e5caab6
--- /dev/null
+++ b/testsuite/gna/bug18280/alias_bug.vhd
@@ -0,0 +1,41 @@
+--
+-- <alias_bug.vhd>
+--
+-- Illustrates GHDL 0.29.1 WinXP problem with attributes and aliases
+--
+-- Problem:
+-- A signal attribute, placed after an alias on the signal, causes errors like this:
+--
+-- .\alias_bug.vhd:35:13: alias "address_ms" does not denote the entire object
+--
+--
+-- Workaround: move the attribute before the alias
+--
+
+library ieee;
+ use ieee.std_logic_1164.all;
+ use ieee.numeric_std.all;
+
+entity alias_bug is
+end alias_bug;
+
+architecture test of alias_bug is
+
+ signal processor_address : std_logic_vector(15 downto 0);
+
+ --
+ -- if alias is _NOT_ declared, error goes away
+ --
+ alias address_ms : std_logic_vector(3 downto 0) is processor_address(15 downto 12);
+
+ --
+ -- if the keep attribute is placed _BEFORE_ the alias, no error occurs
+ --
+ attribute keep : boolean;
+ attribute keep of processor_address: signal is TRUE;
+
+ begin
+
+ processor_address <= X"1234";
+
+ end test;
diff --git a/testsuite/gna/bug18280/ghdc.bat b/testsuite/gna/bug18280/ghdc.bat
new file mode 100644
index 000000000..aca169bb5
--- /dev/null
+++ b/testsuite/gna/bug18280/ghdc.bat
@@ -0,0 +1,2 @@
+ghdl -a alias_bug.vhd
+ghdl -r alias_bug.vhd \ No newline at end of file
diff --git a/testsuite/gna/bug18280/testsuite.sh b/testsuite/gna/bug18280/testsuite.sh
new file mode 100755
index 000000000..8856ba53c
--- /dev/null
+++ b/testsuite/gna/bug18280/testsuite.sh
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+analyze alias_bug.vhd
+elab_simulate alias_bug
+
+clean
+
+echo "Test successful"