diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/vhdl/vhdl-parse.adb | 24 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_expr.adb | 18 |
2 files changed, 36 insertions, 6 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); diff --git a/src/vhdl/vhdl-sem_expr.adb b/src/vhdl/vhdl-sem_expr.adb index 418d3534f..e579aef83 100644 --- a/src/vhdl/vhdl-sem_expr.adb +++ b/src/vhdl/vhdl-sem_expr.adb @@ -4016,10 +4016,20 @@ package body Vhdl.Sem_Expr is return Create_Error_Expr (Res, Error_Mark); end if; - Unit_Name := Sem_Denoting_Name (Unit_Name); - Unit := Get_Named_Entity (Unit_Name); - if Get_Kind (Unit) /= Iir_Kind_Unit_Declaration then - if not Is_Error (Unit) then + case Get_Kind (Unit_Name) is + when Iir_Kind_Simple_Name + | Iir_Kind_Selected_Name => + Unit_Name := Sem_Denoting_Name (Unit_Name); + Unit := Get_Named_Entity (Unit_Name); + when others => + pragma Assert (Flags.Flag_Force_Analysis); + Unit := Null_Iir; + end case; + + if Unit = Null_Iir + or else Get_Kind (Unit) /= Iir_Kind_Unit_Declaration + then + if Unit /= Null_Iir and then not Is_Error (Unit) then Error_Class_Match (Unit_Name, "unit"); end if; Set_Named_Entity (Unit_Name, Create_Error_Name (Unit_Name)); |