aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2016-08-26 04:42:49 +0200
committerTristan Gingold <tgingold@free.fr>2016-08-26 04:42:49 +0200
commit241cee95493ca27931bec90e8d8e584a1da78cab (patch)
treeeab20b9fce6586cee545548cf80664a8845089f7 /src
parent03d8da61cacd965ff35b6ccba9c458cdf8ad8611 (diff)
downloadghdl-241cee95493ca27931bec90e8d8e584a1da78cab.tar.gz
ghdl-241cee95493ca27931bec90e8d8e584a1da78cab.tar.bz2
ghdl-241cee95493ca27931bec90e8d8e584a1da78cab.zip
Avoid a crash on bad component name.
Fixes #144
Diffstat (limited to 'src')
-rw-r--r--src/vhdl/iirs.ads5
-rw-r--r--src/vhdl/parse.adb3
-rw-r--r--src/vhdl/sem_stmts.adb18
3 files changed, 20 insertions, 6 deletions
diff --git a/src/vhdl/iirs.ads b/src/vhdl/iirs.ads
index 7fd10292a..403f63fd1 100644
--- a/src/vhdl/iirs.ads
+++ b/src/vhdl/iirs.ads
@@ -4689,6 +4689,11 @@ package Iirs is
--Iir_Kind_Choice_By_None
Iir_Kind_Choice_By_Name;
+ subtype Iir_Kinds_Entity_Aspect is Iir_Kind range
+ Iir_Kind_Entity_Aspect_Entity ..
+ --Iir_Kind_Entity_Aspect_Configuration
+ Iir_Kind_Entity_Aspect_Open;
+
subtype Iir_Kinds_Denoting_Name is Iir_Kind range
Iir_Kind_Character_Literal ..
--Iir_Kind_Simple_Name
diff --git a/src/vhdl/parse.adb b/src/vhdl/parse.adb
index 575bf6865..aeed1c507 100644
--- a/src/vhdl/parse.adb
+++ b/src/vhdl/parse.adb
@@ -6407,7 +6407,8 @@ package body Parse is
-- INSTANTIATION_label :
-- instantiated_unit [ generic_map_aspect ] [ port_map_aspect ] ;
function Parse_Component_Instantiation (Name: Iir)
- return Iir_Component_Instantiation_Statement is
+ return Iir_Component_Instantiation_Statement
+ is
Res: Iir_Component_Instantiation_Statement;
begin
Res := Create_Iir (Iir_Kind_Component_Instantiation_Statement);
diff --git a/src/vhdl/sem_stmts.adb b/src/vhdl/sem_stmts.adb
index bc5ec9573..7474dbec4 100644
--- a/src/vhdl/sem_stmts.adb
+++ b/src/vhdl/sem_stmts.adb
@@ -1443,7 +1443,9 @@ package body Sem_Stmts is
Comp_Name : Iir;
Comp : Iir;
begin
- if Get_Kind (Inst) in Iir_Kinds_Denoting_Name then
+ if Get_Kind (Inst) in Iir_Kinds_Entity_Aspect then
+ return Sem_Entity_Aspect (Inst);
+ else
Comp := Get_Named_Entity (Inst);
if Comp /= Null_Iir then
-- Already analyzed before, while trying to separate
@@ -1451,6 +1453,13 @@ package body Sem_Stmts is
pragma Assert (Get_Kind (Comp) = Iir_Kind_Component_Declaration);
return Comp;
end if;
+
+ -- Needs a denoting name
+ if Get_Kind (Inst) not in Iir_Kinds_Denoting_Name then
+ Error_Msg_Sem (+Inst, "name for a component expected");
+ return Null_Iir;
+ end if;
+
-- The component may be an entity or a configuration.
Comp_Name := Sem_Denoting_Name (Inst);
Set_Instantiated_Unit (Stmt, Comp_Name);
@@ -1459,9 +1468,8 @@ package body Sem_Stmts is
Error_Class_Match (Comp_Name, "component");
return Null_Iir;
end if;
+
return Comp;
- else
- return Sem_Entity_Aspect (Inst);
end if;
end Sem_Instantiated_Unit;
@@ -1477,7 +1485,7 @@ package body Sem_Stmts is
Error_Msg_Sem (+Stmt, "component instantiation forbidden in entity");
end if;
- -- Check for label.
+ -- Check for label.
-- This cannot be moved in parse since a procedure_call may be revert
-- into a component instantiation.
if Get_Label (Stmt) = Null_Identifier then
@@ -1490,7 +1498,7 @@ package body Sem_Stmts is
return;
end if;
- -- The association
+ -- The association
Sem_Generic_Port_Association_Chain (Decl, Stmt);
-- FIXME: add sources for signals, in order to detect multiple sources