aboutsummaryrefslogtreecommitdiffstats
path: root/sem.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2014-07-19 19:12:51 +0200
committerTristan Gingold <tgingold@free.fr>2014-07-19 19:12:51 +0200
commit348dcc000d792200eb9e9853a1684ab6b3b25764 (patch)
tree27a32cfba7f5b1086f700eb973f2f6a324aa0305 /sem.adb
parentbe1cda652b00ebfe4a9b4ca4e3cda2106586e739 (diff)
downloadghdl-348dcc000d792200eb9e9853a1684ab6b3b25764.tar.gz
ghdl-348dcc000d792200eb9e9853a1684ab6b3b25764.tar.bz2
ghdl-348dcc000d792200eb9e9853a1684ab6b3b25764.zip
Add Entity_Name for architecture and configuration.
Diffstat (limited to 'sem.adb')
-rw-r--r--sem.adb23
1 files changed, 17 insertions, 6 deletions
diff --git a/sem.adb b/sem.adb
index d483ba8bd..56a62615c 100644
--- a/sem.adb
+++ b/sem.adb
@@ -89,14 +89,24 @@ package body Sem is
-- Return NULL_IIR in case of error (not found, bad library).
function Sem_Entity_Name (Library_Unit : Iir) return Iir
is
- Name : Iir;
+ Name : constant Iir := Get_Entity_Name (Library_Unit);
Library : Iir_Library_Declaration;
Entity : Iir;
begin
- Name := Get_Entity (Library_Unit);
+ -- Get the library of architecture/configuration.
Library := Get_Library
(Get_Design_File (Get_Design_Unit (Library_Unit)));
+
if Get_Kind (Name) = Iir_Kind_Simple_Name then
+ -- LRM93 10.1 Declarative Region
+ -- LRM08 12.1 Declarative Region
+ -- a) An entity declaration, tohether with a corresponding
+ -- architecture body.
+ --
+ -- GHDL: simple name needs to be handled specially. Because
+ -- architecture body is in the declarative region of its entity,
+ -- the entity name is directly visible. But we cannot really use
+ -- that rule as is, as we don't know which is the entity.
Entity := Libraries.Load_Primary_Unit
(Library, Get_Identifier (Name), Library_Unit);
if Entity = Null_Iir then
@@ -114,6 +124,7 @@ package body Sem is
end if;
end if;
Xrefs.Xref_Ref (Name, Entity);
+
if Get_Kind (Entity) = Iir_Kind_Entity_Declaration then
-- LRM 1.2 Architecture bodies
-- For a given design entity, both the entity declaration and the
@@ -131,11 +142,11 @@ package body Sem is
return Null_Iir;
end if;
return Entity;
+ else
+ Error_Msg_Sem ("entity name expected, found " & Disp_Node (Entity),
+ Library_Unit);
+ return Null_Iir;
end if;
-
- Error_Msg_Sem ("entity name expected, found " & Disp_Node (Entity),
- Library_Unit);
- return Null_Iir;
end Sem_Entity_Name;
-- LRM 1.2 Architecture bodies.