aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/vhdl-parse.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-08-10 06:03:01 +0200
committerTristan Gingold <tgingold@free.fr>2019-08-10 06:03:01 +0200
commitffd1826443067ed63de998c3a301103305e3ab0d (patch)
tree503a8a7faa2094c3bfa4452d47a97dc290c2844a /src/vhdl/vhdl-parse.adb
parent992a52089e39c5975748ca364971ed61d974a168 (diff)
downloadghdl-ffd1826443067ed63de998c3a301103305e3ab0d.tar.gz
ghdl-ffd1826443067ed63de998c3a301103305e3ab0d.tar.bz2
ghdl-ffd1826443067ed63de998c3a301103305e3ab0d.zip
vhdl: avoid crash on incorrect unit name.
Fix #886
Diffstat (limited to 'src/vhdl/vhdl-parse.adb')
-rw-r--r--src/vhdl/vhdl-parse.adb24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/vhdl/vhdl-parse.adb b/src/vhdl/vhdl-parse.adb
index 7e15589df..8800da259 100644
--- a/src/vhdl/vhdl-parse.adb
+++ b/src/vhdl/vhdl-parse.adb
@@ -5513,6 +5513,26 @@ package body Vhdl.Parse is
end if;
end Resize_Bit_String;
+ -- LRM93 3.1.3
+ -- /unit/_name
+ --
+ -- A unit name is a name, but it must designate a unit declaration. As
+ -- a consequence, it can only be a simple_name or a selected name.
+ function Parse_Unit_Name return Iir
+ is
+ Res : Iir;
+ begin
+ Res := Parse_Name (Allow_Indexes => False);
+ case Get_Kind (Res) is
+ when Iir_Kind_Simple_Name
+ | Iir_Kind_Selected_Name =>
+ null;
+ when others =>
+ Error_Msg_Parse ("invalid unit name");
+ end case;
+ return Res;
+ end Parse_Unit_Name;
+
-- Precond : next token after tok_integer
-- postcond: likewise
--
@@ -5524,7 +5544,7 @@ package body Vhdl.Parse is
if Current_Token = Tok_Identifier then
-- physical literal
Res := Create_Iir (Iir_Kind_Physical_Int_Literal);
- Set_Unit_Name (Res, Parse_Name (Allow_Indexes => False));
+ Set_Unit_Name (Res, Parse_Unit_Name);
else
-- integer literal
Res := Create_Iir (Iir_Kind_Integer_Literal);
@@ -5595,7 +5615,7 @@ package body Vhdl.Parse is
if Current_Token = Tok_Identifier then
-- physical literal
Res := Create_Iir (Iir_Kind_Physical_Fp_Literal);
- Set_Unit_Name (Res, Parse_Name (Allow_Indexes => False));
+ Set_Unit_Name (Res, Parse_Unit_Name);
else
-- real literal
Res := Create_Iir (Iir_Kind_Floating_Point_Literal);