diff options
Diffstat (limited to 'src/vhdl')
-rw-r--r-- | src/vhdl/vhdl-sem_names.adb | 6 | ||||
-rw-r--r-- | src/vhdl/vhdl-utils.adb | 37 |
2 files changed, 29 insertions, 14 deletions
diff --git a/src/vhdl/vhdl-sem_names.adb b/src/vhdl/vhdl-sem_names.adb index b02fdedd4..ebed95997 100644 --- a/src/vhdl/vhdl-sem_names.adb +++ b/src/vhdl/vhdl-sem_names.adb @@ -962,6 +962,7 @@ package body Vhdl.Sem_Names is Parent : Iir; begin if Get_Kind (Base) in Iir_Kinds_Dereference then + -- A dereferenced object is never static. return None; end if; @@ -1039,6 +1040,11 @@ package body Vhdl.Sem_Names is then Prefix := Function_Declaration_To_Call (Prefix); end if; + if not Is_Object_Name (Prefix) then + Error_Msg_Sem_Relaxed + (Attr, Warnid_Attribute, + "prefix of array attribute must be an object name"); + end if; end if; Set_Prefix (Attr, Prefix); diff --git a/src/vhdl/vhdl-utils.adb b/src/vhdl/vhdl-utils.adb index d11b17a2b..421bf4474 100644 --- a/src/vhdl/vhdl-utils.adb +++ b/src/vhdl/vhdl-utils.adb @@ -393,6 +393,10 @@ package body Vhdl.Utils is when Iir_Kind_Slice_Name | Iir_Kind_Indexed_Name | Iir_Kind_Selected_Element => + if Name_To_Object (Get_Prefix (Name)) = Null_Iir then + -- The prefix may not be an object. + return Null_Iir; + end if; return Name; -- An object designated by a value of an access type @@ -1034,20 +1038,25 @@ package body Vhdl.Utils is is Ent : Iir; begin - if Get_Kind (Name) in Iir_Kinds_Denoting_Name then - Ent := Get_Named_Entity (Name); - case Get_Kind (Ent) is - when Iir_Kind_Type_Declaration => - return Get_Type_Definition (Ent); - when Iir_Kind_Subtype_Declaration - | Iir_Kind_Base_Attribute => - return Get_Type (Ent); - when others => - return Null_Iir; - end case; - else - return Null_Iir; - end if; + case Get_Kind (Name) is + when Iir_Kinds_Denoting_Name + | Iir_Kind_Attribute_Name => + Ent := Get_Named_Entity (Name); + case Get_Kind (Ent) is + when Iir_Kind_Type_Declaration => + return Get_Type_Definition (Ent); + when Iir_Kind_Subtype_Declaration + | Iir_Kind_Base_Attribute + | Iir_Kind_Subtype_Attribute => + return Get_Type (Ent); + when others => + return Null_Iir; + end case; + when Iir_Kind_Subtype_Attribute => + return Get_Type (Ent); + when others => + return Null_Iir; + end case; end Is_Type_Name; function Get_Type_Of_Subtype_Indication (Ind : Iir) return Iir is |