aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/sem_names.adb
diff options
context:
space:
mode:
Diffstat (limited to 'src/vhdl/sem_names.adb')
-rw-r--r--src/vhdl/sem_names.adb46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/vhdl/sem_names.adb b/src/vhdl/sem_names.adb
index 6fe3f47d9..1d2865f15 100644
--- a/src/vhdl/sem_names.adb
+++ b/src/vhdl/sem_names.adb
@@ -906,6 +906,44 @@ package body Sem_Names is
return Res;
end Sem_Type_Mark;
+ function Get_Object_Type_Staticness (Name : Iir) return Iir_Staticness
+ is
+ Base : constant Iir := Get_Base_Name (Name);
+ Parent : Iir;
+ begin
+ if Get_Kind (Base) in Iir_Kinds_Dereference then
+ return None;
+ end if;
+
+ Parent := Get_Parent (Base);
+ loop
+ case Get_Kind (Parent) is
+ when Iir_Kind_Entity_Declaration
+ | Iir_Kind_Architecture_Body
+ | Iir_Kind_Block_Statement
+ | Iir_Kind_Block_Header
+ | Iir_Kinds_Process_Statement
+ | Iir_Kind_Generate_Statement_Body
+ | Iir_Kind_Design_Unit =>
+ -- Globally static.
+ return Globally;
+ when Iir_Kind_Package_Declaration
+ | Iir_Kind_Package_Body
+ | Iir_Kind_Package_Instantiation_Declaration
+ | Iir_Kind_Protected_Type_Body =>
+ -- Possibly nested construct.
+ Parent := Get_Parent (Parent);
+ when Iir_Kinds_Subprogram_Declaration
+ | Iir_Kinds_Subprogram_Body
+ | Iir_Kinds_Interface_Subprogram_Declaration =>
+ -- Not globally static.
+ return None;
+ when others =>
+ Error_Kind ("get_object_type_staticness", Parent);
+ end case;
+ end loop;
+ end Get_Object_Type_Staticness;
+
procedure Finish_Sem_Array_Attribute
(Attr_Name : Iir; Attr : Iir; Param : Iir)
is
@@ -914,6 +952,7 @@ package body Sem_Names is
Index_Type : Iir;
Prefix : Iir;
Prefix_Name : Iir;
+ Staticness : Iir_Staticness;
begin
-- LRM93 14.1
-- Parameter: A locally static expression of type universal_integer, the
@@ -1021,7 +1060,12 @@ package body Sem_Names is
-- formed by imposing on an unconstrained array type a globally static
-- index constraint.
- Set_Expr_Staticness (Attr, Get_Type_Staticness (Prefix_Type));
+ Staticness := Get_Type_Staticness (Prefix_Type);
+ if Is_Object_Name (Prefix) then
+ Staticness := Iir_Staticness'Max
+ (Staticness, Get_Object_Type_Staticness (Prefix));
+ end if;
+ Set_Expr_Staticness (Attr, Staticness);
end Finish_Sem_Array_Attribute;
procedure Finish_Sem_Scalar_Type_Attribute