diff options
-rw-r--r-- | pyGHDL/libghdl/vhdl/nodes.py | 13 | ||||
-rw-r--r-- | pyGHDL/libghdl/vhdl/nodes_meta.py | 549 | ||||
-rw-r--r-- | src/synth/synth-vhdl_eval.adb | 70 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes.adb | 16 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes.ads | 6 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes_meta.adb | 388 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes_meta.ads | 2 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_assocs.adb | 3 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_inst.adb | 3 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_scopes.adb | 70 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_scopes.ads | 3 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_stmts.adb | 4 | ||||
-rw-r--r-- | testsuite/gna/issue2250/ent.vhdl | 44 | ||||
-rwxr-xr-x | testsuite/gna/issue2250/testsuite.sh | 11 |
14 files changed, 676 insertions, 506 deletions
diff --git a/pyGHDL/libghdl/vhdl/nodes.py b/pyGHDL/libghdl/vhdl/nodes.py index 40492a9e2..b9de81b8f 100644 --- a/pyGHDL/libghdl/vhdl/nodes.py +++ b/pyGHDL/libghdl/vhdl/nodes.py @@ -3421,6 +3421,19 @@ def Set_Default_Subprogram(obj: Iir, value: Iir) -> None: @export +@BindToLibGHDL("vhdl__nodes__get_associated_subprogram") +def Get_Associated_Subprogram(obj: Iir) -> Iir: + """""" + return 0 + + +@export +@BindToLibGHDL("vhdl__nodes__set_associated_subprogram") +def Set_Associated_Subprogram(obj: Iir, value: Iir) -> None: + """""" + + +@export @BindToLibGHDL("vhdl__nodes__get_subprogram_specification") def Get_Subprogram_Specification(obj: Iir) -> Iir: """""" diff --git a/pyGHDL/libghdl/vhdl/nodes_meta.py b/pyGHDL/libghdl/vhdl/nodes_meta.py index 505c84fb7..a923ac764 100644 --- a/pyGHDL/libghdl/vhdl/nodes_meta.py +++ b/pyGHDL/libghdl/vhdl/nodes_meta.py @@ -228,277 +228,278 @@ class fields(IntEnum): Base_Name = 108 Interface_Declaration_Chain = 109 Default_Subprogram = 110 - Subprogram_Specification = 111 - Sequential_Statement_Chain = 112 - Simultaneous_Statement_Chain = 113 - Subprogram_Body = 114 - Overload_Number = 115 - Subprogram_Depth = 116 - Subprogram_Hash = 117 - Impure_Depth = 118 - Return_Type = 119 - Implicit_Definition = 120 - Uninstantiated_Subprogram_Name = 121 - Default_Value = 122 - Deferred_Declaration = 123 - Deferred_Declaration_Flag = 124 - Shared_Flag = 125 - Design_Unit = 126 - Block_Statement = 127 - Signal_Driver = 128 - Declaration_Chain = 129 - File_Logical_Name = 130 - File_Open_Kind = 131 - Element_Position = 132 - Use_Clause_Chain = 133 - Context_Reference_Chain = 134 - Inherit_Spec_Chain = 135 - Selected_Name = 136 - Type_Declarator = 137 - Complete_Type_Definition = 138 - Incomplete_Type_Ref_Chain = 139 - Associated_Type = 140 - Enumeration_Literal_List = 141 - Entity_Class_Entry_Chain = 142 - Group_Constituent_List = 143 - Unit_Chain = 144 - Primary_Unit = 145 - Identifier = 146 - Label = 147 - Return_Identifier = 148 - Visible_Flag = 149 - Range_Constraint = 150 - Direction = 151 - Left_Limit = 152 - Right_Limit = 153 - Left_Limit_Expr = 154 - Right_Limit_Expr = 155 - Parent_Type = 156 - Simple_Nature = 157 - Base_Nature = 158 - Resolution_Indication = 159 - Record_Element_Resolution_Chain = 160 - Tolerance = 161 - Plus_Terminal_Name = 162 - Minus_Terminal_Name = 163 - Plus_Terminal = 164 - Minus_Terminal = 165 - Magnitude_Expression = 166 - Phase_Expression = 167 - Power_Expression = 168 - Simultaneous_Left = 169 - Simultaneous_Right = 170 - Text_File_Flag = 171 - Only_Characters_Flag = 172 - Is_Character_Type = 173 - Nature_Staticness = 174 - Type_Staticness = 175 - Constraint_State = 176 - Index_Subtype_List = 177 - Index_Subtype_Definition_List = 178 - Element_Subtype_Indication = 179 - Element_Subtype = 180 - Element_Subnature_Indication = 181 - Element_Subnature = 182 - Index_Constraint_List = 183 - Array_Element_Constraint = 184 - Has_Array_Constraint_Flag = 185 - Has_Element_Constraint_Flag = 186 - Elements_Declaration_List = 187 - Owned_Elements_Chain = 188 - Designated_Type = 189 - Designated_Subtype_Indication = 190 - Index_List = 191 - Reference = 192 - Nature_Declarator = 193 - Across_Type_Mark = 194 - Through_Type_Mark = 195 - Across_Type_Definition = 196 - Through_Type_Definition = 197 - Across_Type = 198 - Through_Type = 199 - Target = 200 - Waveform_Chain = 201 - Guard = 202 - Delay_Mechanism = 203 - Reject_Time_Expression = 204 - Force_Mode = 205 - Has_Force_Mode = 206 - Sensitivity_List = 207 - Process_Origin = 208 - Package_Origin = 209 - Condition_Clause = 210 - Break_Element = 211 - Selector_Quantity = 212 - Break_Quantity = 213 - Timeout_Clause = 214 - Postponed_Flag = 215 - Callees_List = 216 - Passive_Flag = 217 - Resolution_Function_Flag = 218 - Wait_State = 219 - All_Sensitized_State = 220 - Seen_Flag = 221 - Pure_Flag = 222 - Foreign_Flag = 223 - Resolved_Flag = 224 - Signal_Type_Flag = 225 - Has_Signal_Flag = 226 - Purity_State = 227 - Elab_Flag = 228 - Vendor_Library_Flag = 229 - Configuration_Mark_Flag = 230 - Configuration_Done_Flag = 231 - Index_Constraint_Flag = 232 - Hide_Implicit_Flag = 233 - Assertion_Condition = 234 - Report_Expression = 235 - Severity_Expression = 236 - Instantiated_Unit = 237 - Generic_Map_Aspect_Chain = 238 - Port_Map_Aspect_Chain = 239 - Configuration_Name = 240 - Component_Configuration = 241 - Configuration_Specification = 242 - Default_Binding_Indication = 243 - Default_Configuration_Declaration = 244 - Expression = 245 - Conditional_Expression_Chain = 246 - Allocator_Designated_Type = 247 - Selected_Waveform_Chain = 248 - Conditional_Waveform_Chain = 249 - Guard_Expression = 250 - Guard_Decl = 251 - Guard_Sensitivity_List = 252 - Attribute_Implicit_Chain = 253 - Block_Block_Configuration = 254 - Package_Header = 255 - Block_Header = 256 - Uninstantiated_Package_Name = 257 - Uninstantiated_Package_Decl = 258 - Instance_Source_File = 259 - Generate_Block_Configuration = 260 - Generate_Statement_Body = 261 - Alternative_Label = 262 - Generate_Else_Clause = 263 - Condition = 264 - Else_Clause = 265 - Parameter_Specification = 266 - Parent = 267 - Loop_Label = 268 - Exit_Flag = 269 - Next_Flag = 270 - Component_Name = 271 - Instantiation_List = 272 - Entity_Aspect = 273 - Default_Entity_Aspect = 274 - Binding_Indication = 275 - Named_Entity = 276 - Referenced_Name = 277 - Expr_Staticness = 278 - Scalar_Size = 279 - Error_Origin = 280 - Operand = 281 - Left = 282 - Right = 283 - Unit_Name = 284 - Name = 285 - Group_Template_Name = 286 - Name_Staticness = 287 - Prefix = 288 - Signature_Prefix = 289 - External_Pathname = 290 - Pathname_Suffix = 291 - Pathname_Expression = 292 - In_Formal_Flag = 293 - Inertial_Flag = 294 - Slice_Subtype = 295 - Suffix = 296 - Index_Subtype = 297 - Parameter = 298 - Parameter_2 = 299 - Parameter_3 = 300 - Parameter_4 = 301 - Attr_Chain = 302 - Attribute_Implicit_Declaration = 303 - Actual_Type = 304 - Actual_Type_Definition = 305 - Association_Chain = 306 - Individual_Association_Chain = 307 - Subprogram_Association_Chain = 308 - Aggregate_Info = 309 - Sub_Aggregate_Info = 310 - Aggr_Dynamic_Flag = 311 - Aggr_Min_Length = 312 - Aggr_Low_Limit = 313 - Aggr_High_Limit = 314 - Aggr_Others_Flag = 315 - Aggr_Named_Flag = 316 - Aggregate_Expand_Flag = 317 - Determined_Aggregate_Flag = 318 - Association_Choices_Chain = 319 - Case_Statement_Alternative_Chain = 320 - Matching_Flag = 321 - Choice_Staticness = 322 - Procedure_Call = 323 - Implementation = 324 - Parameter_Association_Chain = 325 - Method_Object = 326 - Subtype_Type_Mark = 327 - Subnature_Nature_Mark = 328 - Type_Conversion_Subtype = 329 - Type_Mark = 330 - File_Type_Mark = 331 - Return_Type_Mark = 332 - Has_Disconnect_Flag = 333 - Has_Active_Flag = 334 - Is_Within_Flag = 335 - Type_Marks_List = 336 - Implicit_Alias_Flag = 337 - Alias_Signature = 338 - Attribute_Signature = 339 - Overload_List = 340 - Simple_Name_Identifier = 341 - Simple_Name_Subtype = 342 - Protected_Type_Body = 343 - Protected_Type_Declaration = 344 - Use_Flag = 345 - End_Has_Reserved_Id = 346 - End_Has_Identifier = 347 - End_Has_Postponed = 348 - Has_Label = 349 - Has_Begin = 350 - Has_End = 351 - Has_Is = 352 - Has_Pure = 353 - Has_Body = 354 - Has_Parameter = 355 - Has_Component = 356 - Has_Identifier_List = 357 - Has_Mode = 358 - Has_Class = 359 - Has_Delay_Mechanism = 360 - Suspend_Flag = 361 - Stop_Flag = 362 - Is_Ref = 363 - Is_Forward_Ref = 364 - Psl_Property = 365 - Psl_Sequence = 366 - Psl_Declaration = 367 - Psl_Expression = 368 - Psl_Boolean = 369 - PSL_Clock = 370 - PSL_NFA = 371 - PSL_Nbr_States = 372 - PSL_Clock_Sensitivity = 373 - PSL_EOS_Flag = 374 - PSL_Abort_Flag = 375 - Count_Expression = 376 - Clock_Expression = 377 - Default_Clock = 378 - Foreign_Node = 379 - Suspend_State_Index = 380 - Suspend_State_Chain = 381 + Associated_Subprogram = 111 + Subprogram_Specification = 112 + Sequential_Statement_Chain = 113 + Simultaneous_Statement_Chain = 114 + Subprogram_Body = 115 + Overload_Number = 116 + Subprogram_Depth = 117 + Subprogram_Hash = 118 + Impure_Depth = 119 + Return_Type = 120 + Implicit_Definition = 121 + Uninstantiated_Subprogram_Name = 122 + Default_Value = 123 + Deferred_Declaration = 124 + Deferred_Declaration_Flag = 125 + Shared_Flag = 126 + Design_Unit = 127 + Block_Statement = 128 + Signal_Driver = 129 + Declaration_Chain = 130 + File_Logical_Name = 131 + File_Open_Kind = 132 + Element_Position = 133 + Use_Clause_Chain = 134 + Context_Reference_Chain = 135 + Inherit_Spec_Chain = 136 + Selected_Name = 137 + Type_Declarator = 138 + Complete_Type_Definition = 139 + Incomplete_Type_Ref_Chain = 140 + Associated_Type = 141 + Enumeration_Literal_List = 142 + Entity_Class_Entry_Chain = 143 + Group_Constituent_List = 144 + Unit_Chain = 145 + Primary_Unit = 146 + Identifier = 147 + Label = 148 + Return_Identifier = 149 + Visible_Flag = 150 + Range_Constraint = 151 + Direction = 152 + Left_Limit = 153 + Right_Limit = 154 + Left_Limit_Expr = 155 + Right_Limit_Expr = 156 + Parent_Type = 157 + Simple_Nature = 158 + Base_Nature = 159 + Resolution_Indication = 160 + Record_Element_Resolution_Chain = 161 + Tolerance = 162 + Plus_Terminal_Name = 163 + Minus_Terminal_Name = 164 + Plus_Terminal = 165 + Minus_Terminal = 166 + Magnitude_Expression = 167 + Phase_Expression = 168 + Power_Expression = 169 + Simultaneous_Left = 170 + Simultaneous_Right = 171 + Text_File_Flag = 172 + Only_Characters_Flag = 173 + Is_Character_Type = 174 + Nature_Staticness = 175 + Type_Staticness = 176 + Constraint_State = 177 + Index_Subtype_List = 178 + Index_Subtype_Definition_List = 179 + Element_Subtype_Indication = 180 + Element_Subtype = 181 + Element_Subnature_Indication = 182 + Element_Subnature = 183 + Index_Constraint_List = 184 + Array_Element_Constraint = 185 + Has_Array_Constraint_Flag = 186 + Has_Element_Constraint_Flag = 187 + Elements_Declaration_List = 188 + Owned_Elements_Chain = 189 + Designated_Type = 190 + Designated_Subtype_Indication = 191 + Index_List = 192 + Reference = 193 + Nature_Declarator = 194 + Across_Type_Mark = 195 + Through_Type_Mark = 196 + Across_Type_Definition = 197 + Through_Type_Definition = 198 + Across_Type = 199 + Through_Type = 200 + Target = 201 + Waveform_Chain = 202 + Guard = 203 + Delay_Mechanism = 204 + Reject_Time_Expression = 205 + Force_Mode = 206 + Has_Force_Mode = 207 + Sensitivity_List = 208 + Process_Origin = 209 + Package_Origin = 210 + Condition_Clause = 211 + Break_Element = 212 + Selector_Quantity = 213 + Break_Quantity = 214 + Timeout_Clause = 215 + Postponed_Flag = 216 + Callees_List = 217 + Passive_Flag = 218 + Resolution_Function_Flag = 219 + Wait_State = 220 + All_Sensitized_State = 221 + Seen_Flag = 222 + Pure_Flag = 223 + Foreign_Flag = 224 + Resolved_Flag = 225 + Signal_Type_Flag = 226 + Has_Signal_Flag = 227 + Purity_State = 228 + Elab_Flag = 229 + Vendor_Library_Flag = 230 + Configuration_Mark_Flag = 231 + Configuration_Done_Flag = 232 + Index_Constraint_Flag = 233 + Hide_Implicit_Flag = 234 + Assertion_Condition = 235 + Report_Expression = 236 + Severity_Expression = 237 + Instantiated_Unit = 238 + Generic_Map_Aspect_Chain = 239 + Port_Map_Aspect_Chain = 240 + Configuration_Name = 241 + Component_Configuration = 242 + Configuration_Specification = 243 + Default_Binding_Indication = 244 + Default_Configuration_Declaration = 245 + Expression = 246 + Conditional_Expression_Chain = 247 + Allocator_Designated_Type = 248 + Selected_Waveform_Chain = 249 + Conditional_Waveform_Chain = 250 + Guard_Expression = 251 + Guard_Decl = 252 + Guard_Sensitivity_List = 253 + Attribute_Implicit_Chain = 254 + Block_Block_Configuration = 255 + Package_Header = 256 + Block_Header = 257 + Uninstantiated_Package_Name = 258 + Uninstantiated_Package_Decl = 259 + Instance_Source_File = 260 + Generate_Block_Configuration = 261 + Generate_Statement_Body = 262 + Alternative_Label = 263 + Generate_Else_Clause = 264 + Condition = 265 + Else_Clause = 266 + Parameter_Specification = 267 + Parent = 268 + Loop_Label = 269 + Exit_Flag = 270 + Next_Flag = 271 + Component_Name = 272 + Instantiation_List = 273 + Entity_Aspect = 274 + Default_Entity_Aspect = 275 + Binding_Indication = 276 + Named_Entity = 277 + Referenced_Name = 278 + Expr_Staticness = 279 + Scalar_Size = 280 + Error_Origin = 281 + Operand = 282 + Left = 283 + Right = 284 + Unit_Name = 285 + Name = 286 + Group_Template_Name = 287 + Name_Staticness = 288 + Prefix = 289 + Signature_Prefix = 290 + External_Pathname = 291 + Pathname_Suffix = 292 + Pathname_Expression = 293 + In_Formal_Flag = 294 + Inertial_Flag = 295 + Slice_Subtype = 296 + Suffix = 297 + Index_Subtype = 298 + Parameter = 299 + Parameter_2 = 300 + Parameter_3 = 301 + Parameter_4 = 302 + Attr_Chain = 303 + Attribute_Implicit_Declaration = 304 + Actual_Type = 305 + Actual_Type_Definition = 306 + Association_Chain = 307 + Individual_Association_Chain = 308 + Subprogram_Association_Chain = 309 + Aggregate_Info = 310 + Sub_Aggregate_Info = 311 + Aggr_Dynamic_Flag = 312 + Aggr_Min_Length = 313 + Aggr_Low_Limit = 314 + Aggr_High_Limit = 315 + Aggr_Others_Flag = 316 + Aggr_Named_Flag = 317 + Aggregate_Expand_Flag = 318 + Determined_Aggregate_Flag = 319 + Association_Choices_Chain = 320 + Case_Statement_Alternative_Chain = 321 + Matching_Flag = 322 + Choice_Staticness = 323 + Procedure_Call = 324 + Implementation = 325 + Parameter_Association_Chain = 326 + Method_Object = 327 + Subtype_Type_Mark = 328 + Subnature_Nature_Mark = 329 + Type_Conversion_Subtype = 330 + Type_Mark = 331 + File_Type_Mark = 332 + Return_Type_Mark = 333 + Has_Disconnect_Flag = 334 + Has_Active_Flag = 335 + Is_Within_Flag = 336 + Type_Marks_List = 337 + Implicit_Alias_Flag = 338 + Alias_Signature = 339 + Attribute_Signature = 340 + Overload_List = 341 + Simple_Name_Identifier = 342 + Simple_Name_Subtype = 343 + Protected_Type_Body = 344 + Protected_Type_Declaration = 345 + Use_Flag = 346 + End_Has_Reserved_Id = 347 + End_Has_Identifier = 348 + End_Has_Postponed = 349 + Has_Label = 350 + Has_Begin = 351 + Has_End = 352 + Has_Is = 353 + Has_Pure = 354 + Has_Body = 355 + Has_Parameter = 356 + Has_Component = 357 + Has_Identifier_List = 358 + Has_Mode = 359 + Has_Class = 360 + Has_Delay_Mechanism = 361 + Suspend_Flag = 362 + Stop_Flag = 363 + Is_Ref = 364 + Is_Forward_Ref = 365 + Psl_Property = 366 + Psl_Sequence = 367 + Psl_Declaration = 368 + Psl_Expression = 369 + Psl_Boolean = 370 + PSL_Clock = 371 + PSL_NFA = 372 + PSL_Nbr_States = 373 + PSL_Clock_Sensitivity = 374 + PSL_EOS_Flag = 375 + PSL_Abort_Flag = 376 + Count_Expression = 377 + Clock_Expression = 378 + Default_Clock = 379 + Foreign_Node = 380 + Suspend_State_Index = 381 + Suspend_State_Chain = 382 def Get_Boolean(node, field): @@ -1300,6 +1301,12 @@ def Has_Default_Subprogram(kind: IirKind) -> bool: @export +@BindToLibGHDL("vhdl__nodes_meta__has_associated_subprogram") +def Has_Associated_Subprogram(kind: IirKind) -> bool: + """""" + + +@export @BindToLibGHDL("vhdl__nodes_meta__has_subprogram_specification") def Has_Subprogram_Specification(kind: IirKind) -> bool: """""" diff --git a/src/synth/synth-vhdl_eval.adb b/src/synth/synth-vhdl_eval.adb index f5be3d91d..31592bb59 100644 --- a/src/synth/synth-vhdl_eval.adb +++ b/src/synth/synth-vhdl_eval.adb @@ -908,6 +908,41 @@ package body Synth.Vhdl_Eval is | Iir_Predefined_Bit_Not => return Create_Memory_U8 (1 - Read_U8 (Param1), Param1.Typ); + when Iir_Predefined_Boolean_Or + | Iir_Predefined_Bit_Or + | Iir_Predefined_Boolean_And + | Iir_Predefined_Bit_And => + -- Short-circuit operators. + raise Internal_Error; + + when Iir_Predefined_Boolean_Rising_Edge + | Iir_Predefined_Boolean_Falling_Edge + | Iir_Predefined_Bit_Rising_Edge + | Iir_Predefined_Bit_Falling_Edge => + -- Cannot be static + raise Internal_Error; + + when Iir_Predefined_Boolean_Xor + | Iir_Predefined_Bit_Xor => + return Create_Memory_U8 + (Boolean'Pos (Boolean'Val (Read_Discrete (Param1)) + xor Boolean'Val (Read_Discrete (Param2))), + Res_Typ); + + when Iir_Predefined_Boolean_Nand + | Iir_Predefined_Bit_Nand => + return Create_Memory_U8 + (Boolean'Pos (not (Boolean'Val (Read_Discrete (Param1)) + and Boolean'Val (Read_Discrete (Param2)))), + Res_Typ); + + when Iir_Predefined_Boolean_Nor + | Iir_Predefined_Bit_Nor => + return Create_Memory_U8 + (Boolean'Pos (not (Boolean'Val (Read_Discrete (Param1)) + or Boolean'Val (Read_Discrete (Param2)))), + Res_Typ); + when Iir_Predefined_Bit_Condition => return Create_Memory_U8 (Read_U8 (Param1), Param1.Typ); @@ -1022,34 +1057,6 @@ package body Synth.Vhdl_Eval is | Iir_Predefined_Ieee_Std_Logic_Signed_Abs_Slv => return Abs_Sgn_Sgn (Param1, +Expr); - when Iir_Predefined_Boolean_Or - | Iir_Predefined_Bit_Or - | Iir_Predefined_Boolean_And - | Iir_Predefined_Bit_And => - -- Short-circuit operators. - raise Internal_Error; - - when Iir_Predefined_Boolean_Xor - | Iir_Predefined_Bit_Xor => - return Create_Memory_U8 - (Boolean'Pos (Boolean'Val (Read_Discrete (Param1)) - xor Boolean'Val (Read_Discrete (Param2))), - Res_Typ); - - when Iir_Predefined_Boolean_Nand - | Iir_Predefined_Bit_Nand => - return Create_Memory_U8 - (Boolean'Pos (not (Boolean'Val (Read_Discrete (Param1)) - and Boolean'Val (Read_Discrete (Param2)))), - Res_Typ); - - when Iir_Predefined_Boolean_Nor - | Iir_Predefined_Bit_Nor => - return Create_Memory_U8 - (Boolean'Pos (not (Boolean'Val (Read_Discrete (Param1)) - or Boolean'Val (Read_Discrete (Param2)))), - Res_Typ); - when Iir_Predefined_Integer_Plus | Iir_Predefined_Physical_Plus => declare @@ -2985,10 +2992,9 @@ package body Synth.Vhdl_Eval is return Create_Memory_Fp64 (Res, Res_Typ); end; when others => - null; + Error_Msg_Synth (Inst, Expr, "unhandled (static) function: " + & Iir_Predefined_Functions'Image (Def)); + return Null_Memtyp; end case; - Error_Msg_Synth (Inst, Expr, "unhandled (static) function: " - & Iir_Predefined_Functions'Image (Def)); - return Null_Memtyp; end Eval_Static_Predefined_Function_Call; end Synth.Vhdl_Eval; diff --git a/src/vhdl/vhdl-nodes.adb b/src/vhdl/vhdl-nodes.adb index 5fac95d66..07ed95bfd 100644 --- a/src/vhdl/vhdl-nodes.adb +++ b/src/vhdl/vhdl-nodes.adb @@ -3182,6 +3182,22 @@ package body Vhdl.Nodes is Set_Field9 (Inter, Subprg); end Set_Default_Subprogram; + function Get_Associated_Subprogram (Inter : Iir) return Iir is + begin + pragma Assert (Inter /= Null_Iir); + pragma Assert (Has_Associated_Subprogram (Get_Kind (Inter)), + "no field Associated_Subprogram"); + return Get_Field6 (Inter); + end Get_Associated_Subprogram; + + procedure Set_Associated_Subprogram (Inter : Iir; Subprg : Iir) is + begin + pragma Assert (Inter /= Null_Iir); + pragma Assert (Has_Associated_Subprogram (Get_Kind (Inter)), + "no field Associated_Subprogram"); + Set_Field6 (Inter, Subprg); + end Set_Associated_Subprogram; + function Get_Subprogram_Specification (Target : Iir) return Iir is begin pragma Assert (Target /= Null_Iir); diff --git a/src/vhdl/vhdl-nodes.ads b/src/vhdl/vhdl-nodes.ads index a82fc46c1..529790b9a 100644 --- a/src/vhdl/vhdl-nodes.ads +++ b/src/vhdl/vhdl-nodes.ads @@ -1782,6 +1782,8 @@ package Vhdl.Nodes is -- -- Get/Set_Subprogram_Depth (Field10) -- + -- Get/Set_Associated_Subprogram (Field6) + -- -- Get/Set_Seen_Flag (Flag1) -- -- Only for Iir_Kind_Interface_Function_Declaration: @@ -8262,6 +8264,10 @@ package Vhdl.Nodes is procedure Set_Default_Subprogram (Inter : Iir; Subprg : Iir); -- Field: Field6 Ref + function Get_Associated_Subprogram (Inter : Iir) return Iir; + procedure Set_Associated_Subprogram (Inter : Iir; Subprg : Iir); + + -- Field: Field6 Ref function Get_Subprogram_Specification (Target : Iir) return Iir; procedure Set_Subprogram_Specification (Target : Iir; Spec : Iir); diff --git a/src/vhdl/vhdl-nodes_meta.adb b/src/vhdl/vhdl-nodes_meta.adb index 20ed0a51f..526b6554b 100644 --- a/src/vhdl/vhdl-nodes_meta.adb +++ b/src/vhdl/vhdl-nodes_meta.adb @@ -128,6 +128,7 @@ package body Vhdl.Nodes_Meta is Field_Base_Name => Type_Iir, Field_Interface_Declaration_Chain => Type_Iir, Field_Default_Subprogram => Type_Iir, + Field_Associated_Subprogram => Type_Iir, Field_Subprogram_Specification => Type_Iir, Field_Sequential_Statement_Chain => Type_Iir, Field_Simultaneous_Statement_Chain => Type_Iir, @@ -631,6 +632,8 @@ package body Vhdl.Nodes_Meta is return "interface_declaration_chain"; when Field_Default_Subprogram => return "default_subprogram"; + when Field_Associated_Subprogram => + return "associated_subprogram"; when Field_Subprogram_Specification => return "subprogram_specification"; when Field_Sequential_Statement_Chain => @@ -2055,6 +2058,8 @@ package body Vhdl.Nodes_Meta is return Attr_Chain; when Field_Default_Subprogram => return Attr_None; + when Field_Associated_Subprogram => + return Attr_Ref; when Field_Subprogram_Specification => return Attr_Ref; when Field_Sequential_Statement_Chain => @@ -3979,6 +3984,7 @@ package body Vhdl.Nodes_Meta is Field_Interface_Declaration_Chain, Field_Return_Type_Mark, Field_Default_Subprogram, + Field_Associated_Subprogram, -- Iir_Kind_Interface_Procedure_Declaration Field_Subprogram_Depth, Field_Identifier, @@ -3995,6 +4001,7 @@ package body Vhdl.Nodes_Meta is Field_Interface_Declaration_Chain, Field_Return_Type_Mark, Field_Default_Subprogram, + Field_Associated_Subprogram, -- Iir_Kind_Attribute_Implicit_Declaration Field_Parent, Field_Chain, @@ -5493,189 +5500,189 @@ package body Vhdl.Nodes_Meta is Iir_Kind_Interface_Terminal_Declaration => 1190, Iir_Kind_Interface_Type_Declaration => 1202, Iir_Kind_Interface_Package_Declaration => 1215, - Iir_Kind_Interface_Function_Declaration => 1234, - Iir_Kind_Interface_Procedure_Declaration => 1249, - Iir_Kind_Attribute_Implicit_Declaration => 1252, - Iir_Kind_Suspend_State_Declaration => 1255, - Iir_Kind_Identity_Operator => 1259, - Iir_Kind_Negation_Operator => 1263, - Iir_Kind_Absolute_Operator => 1267, - Iir_Kind_Not_Operator => 1271, - Iir_Kind_Implicit_Condition_Operator => 1275, - Iir_Kind_Condition_Operator => 1279, - Iir_Kind_Reduction_And_Operator => 1283, - Iir_Kind_Reduction_Or_Operator => 1287, - Iir_Kind_Reduction_Nand_Operator => 1291, - Iir_Kind_Reduction_Nor_Operator => 1295, - Iir_Kind_Reduction_Xor_Operator => 1299, - Iir_Kind_Reduction_Xnor_Operator => 1303, - Iir_Kind_And_Operator => 1308, - Iir_Kind_Or_Operator => 1313, - Iir_Kind_Nand_Operator => 1318, - Iir_Kind_Nor_Operator => 1323, - Iir_Kind_Xor_Operator => 1328, - Iir_Kind_Xnor_Operator => 1333, - Iir_Kind_Equality_Operator => 1338, - Iir_Kind_Inequality_Operator => 1343, - Iir_Kind_Less_Than_Operator => 1348, - Iir_Kind_Less_Than_Or_Equal_Operator => 1353, - Iir_Kind_Greater_Than_Operator => 1358, - Iir_Kind_Greater_Than_Or_Equal_Operator => 1363, - Iir_Kind_Match_Equality_Operator => 1368, - Iir_Kind_Match_Inequality_Operator => 1373, - Iir_Kind_Match_Less_Than_Operator => 1378, - Iir_Kind_Match_Less_Than_Or_Equal_Operator => 1383, - Iir_Kind_Match_Greater_Than_Operator => 1388, - Iir_Kind_Match_Greater_Than_Or_Equal_Operator => 1393, - Iir_Kind_Sll_Operator => 1398, - Iir_Kind_Sla_Operator => 1403, - Iir_Kind_Srl_Operator => 1408, - Iir_Kind_Sra_Operator => 1413, - Iir_Kind_Rol_Operator => 1418, - Iir_Kind_Ror_Operator => 1423, - Iir_Kind_Addition_Operator => 1428, - Iir_Kind_Substraction_Operator => 1433, - Iir_Kind_Concatenation_Operator => 1438, - Iir_Kind_Multiplication_Operator => 1443, - Iir_Kind_Division_Operator => 1448, - Iir_Kind_Modulus_Operator => 1453, - Iir_Kind_Remainder_Operator => 1458, - Iir_Kind_Exponentiation_Operator => 1463, - Iir_Kind_Function_Call => 1471, - Iir_Kind_Aggregate => 1479, - Iir_Kind_Parenthesis_Expression => 1482, - Iir_Kind_Qualified_Expression => 1486, - Iir_Kind_Type_Conversion => 1491, - Iir_Kind_Allocator_By_Expression => 1496, - Iir_Kind_Allocator_By_Subtype => 1502, - Iir_Kind_Selected_Element => 1510, - Iir_Kind_Dereference => 1515, - Iir_Kind_Implicit_Dereference => 1520, - Iir_Kind_Slice_Name => 1527, - Iir_Kind_Indexed_Name => 1533, - Iir_Kind_Psl_Prev => 1539, - Iir_Kind_Psl_Stable => 1544, - Iir_Kind_Psl_Rose => 1549, - Iir_Kind_Psl_Fell => 1554, - Iir_Kind_Psl_Onehot => 1557, - Iir_Kind_Psl_Onehot0 => 1560, - Iir_Kind_Psl_Expression => 1562, - Iir_Kind_Sensitized_Process_Statement => 1584, - Iir_Kind_Process_Statement => 1605, - Iir_Kind_Concurrent_Simple_Signal_Assignment => 1618, - Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1631, - Iir_Kind_Concurrent_Selected_Signal_Assignment => 1645, - Iir_Kind_Concurrent_Assertion_Statement => 1653, - Iir_Kind_Concurrent_Procedure_Call_Statement => 1660, - Iir_Kind_Concurrent_Break_Statement => 1668, - Iir_Kind_Psl_Assert_Directive => 1682, - Iir_Kind_Psl_Assume_Directive => 1694, - Iir_Kind_Psl_Cover_Directive => 1706, - Iir_Kind_Psl_Restrict_Directive => 1717, - Iir_Kind_Block_Statement => 1731, - Iir_Kind_If_Generate_Statement => 1742, - Iir_Kind_Case_Generate_Statement => 1751, - Iir_Kind_For_Generate_Statement => 1760, - Iir_Kind_Component_Instantiation_Statement => 1771, - Iir_Kind_Psl_Default_Clock => 1774, - Iir_Kind_Generate_Statement_Body => 1785, - Iir_Kind_If_Generate_Else_Clause => 1791, - Iir_Kind_Simple_Simultaneous_Statement => 1798, - Iir_Kind_Simultaneous_Null_Statement => 1802, - Iir_Kind_Simultaneous_Procedural_Statement => 1813, - Iir_Kind_Simultaneous_Case_Statement => 1822, - Iir_Kind_Simultaneous_If_Statement => 1831, - Iir_Kind_Simultaneous_Elsif => 1837, - Iir_Kind_Simple_Signal_Assignment_Statement => 1848, - Iir_Kind_Conditional_Signal_Assignment_Statement => 1859, - Iir_Kind_Selected_Waveform_Assignment_Statement => 1871, - Iir_Kind_Signal_Force_Assignment_Statement => 1881, - Iir_Kind_Signal_Release_Assignment_Statement => 1890, - Iir_Kind_Null_Statement => 1894, - Iir_Kind_Assertion_Statement => 1901, - Iir_Kind_Report_Statement => 1907, - Iir_Kind_Wait_Statement => 1915, - Iir_Kind_Variable_Assignment_Statement => 1922, - Iir_Kind_Conditional_Variable_Assignment_Statement => 1929, - Iir_Kind_Return_Statement => 1935, - Iir_Kind_For_Loop_Statement => 1946, - Iir_Kind_While_Loop_Statement => 1957, - Iir_Kind_Next_Statement => 1964, - Iir_Kind_Exit_Statement => 1971, - Iir_Kind_Case_Statement => 1980, - Iir_Kind_Procedure_Call_Statement => 1986, - Iir_Kind_Break_Statement => 1993, - Iir_Kind_If_Statement => 2003, - Iir_Kind_Suspend_State_Statement => 2007, - Iir_Kind_Elsif => 2013, - Iir_Kind_Character_Literal => 2020, - Iir_Kind_Simple_Name => 2027, - Iir_Kind_Selected_Name => 2035, - Iir_Kind_Operator_Symbol => 2040, - Iir_Kind_Reference_Name => 2045, - Iir_Kind_External_Constant_Name => 2054, - Iir_Kind_External_Signal_Name => 2064, - Iir_Kind_External_Variable_Name => 2074, - Iir_Kind_Selected_By_All_Name => 2080, - Iir_Kind_Parenthesis_Name => 2085, - Iir_Kind_Package_Pathname => 2089, - Iir_Kind_Absolute_Pathname => 2090, - Iir_Kind_Relative_Pathname => 2091, - Iir_Kind_Pathname_Element => 2096, - Iir_Kind_Base_Attribute => 2098, - Iir_Kind_Subtype_Attribute => 2103, - Iir_Kind_Element_Attribute => 2108, - Iir_Kind_Across_Attribute => 2113, - Iir_Kind_Through_Attribute => 2118, - Iir_Kind_Nature_Reference_Attribute => 2122, - Iir_Kind_Left_Type_Attribute => 2127, - Iir_Kind_Right_Type_Attribute => 2132, - Iir_Kind_High_Type_Attribute => 2137, - Iir_Kind_Low_Type_Attribute => 2142, - Iir_Kind_Ascending_Type_Attribute => 2147, - Iir_Kind_Image_Attribute => 2153, - Iir_Kind_Value_Attribute => 2159, - Iir_Kind_Pos_Attribute => 2165, - Iir_Kind_Val_Attribute => 2171, - Iir_Kind_Succ_Attribute => 2177, - Iir_Kind_Pred_Attribute => 2183, - Iir_Kind_Leftof_Attribute => 2189, - Iir_Kind_Rightof_Attribute => 2195, - Iir_Kind_Signal_Slew_Attribute => 2203, - Iir_Kind_Quantity_Slew_Attribute => 2211, - Iir_Kind_Ramp_Attribute => 2219, - Iir_Kind_Zoh_Attribute => 2227, - Iir_Kind_Ltf_Attribute => 2235, - Iir_Kind_Ztf_Attribute => 2245, - Iir_Kind_Dot_Attribute => 2252, - Iir_Kind_Integ_Attribute => 2259, - Iir_Kind_Quantity_Delayed_Attribute => 2267, - Iir_Kind_Above_Attribute => 2275, - Iir_Kind_Delayed_Attribute => 2284, - Iir_Kind_Stable_Attribute => 2293, - Iir_Kind_Quiet_Attribute => 2302, - Iir_Kind_Transaction_Attribute => 2311, - Iir_Kind_Event_Attribute => 2315, - Iir_Kind_Active_Attribute => 2319, - Iir_Kind_Last_Event_Attribute => 2323, - Iir_Kind_Last_Active_Attribute => 2327, - Iir_Kind_Last_Value_Attribute => 2331, - Iir_Kind_Driving_Attribute => 2335, - Iir_Kind_Driving_Value_Attribute => 2339, - Iir_Kind_Behavior_Attribute => 2339, - Iir_Kind_Structure_Attribute => 2339, - Iir_Kind_Simple_Name_Attribute => 2346, - Iir_Kind_Instance_Name_Attribute => 2351, - Iir_Kind_Path_Name_Attribute => 2356, - Iir_Kind_Left_Array_Attribute => 2363, - Iir_Kind_Right_Array_Attribute => 2370, - Iir_Kind_High_Array_Attribute => 2377, - Iir_Kind_Low_Array_Attribute => 2384, - Iir_Kind_Length_Array_Attribute => 2391, - Iir_Kind_Ascending_Array_Attribute => 2398, - Iir_Kind_Range_Array_Attribute => 2405, - Iir_Kind_Reverse_Range_Array_Attribute => 2412, - Iir_Kind_Attribute_Name => 2421 + Iir_Kind_Interface_Function_Declaration => 1235, + Iir_Kind_Interface_Procedure_Declaration => 1251, + Iir_Kind_Attribute_Implicit_Declaration => 1254, + Iir_Kind_Suspend_State_Declaration => 1257, + Iir_Kind_Identity_Operator => 1261, + Iir_Kind_Negation_Operator => 1265, + Iir_Kind_Absolute_Operator => 1269, + Iir_Kind_Not_Operator => 1273, + Iir_Kind_Implicit_Condition_Operator => 1277, + Iir_Kind_Condition_Operator => 1281, + Iir_Kind_Reduction_And_Operator => 1285, + Iir_Kind_Reduction_Or_Operator => 1289, + Iir_Kind_Reduction_Nand_Operator => 1293, + Iir_Kind_Reduction_Nor_Operator => 1297, + Iir_Kind_Reduction_Xor_Operator => 1301, + Iir_Kind_Reduction_Xnor_Operator => 1305, + Iir_Kind_And_Operator => 1310, + Iir_Kind_Or_Operator => 1315, + Iir_Kind_Nand_Operator => 1320, + Iir_Kind_Nor_Operator => 1325, + Iir_Kind_Xor_Operator => 1330, + Iir_Kind_Xnor_Operator => 1335, + Iir_Kind_Equality_Operator => 1340, + Iir_Kind_Inequality_Operator => 1345, + Iir_Kind_Less_Than_Operator => 1350, + Iir_Kind_Less_Than_Or_Equal_Operator => 1355, + Iir_Kind_Greater_Than_Operator => 1360, + Iir_Kind_Greater_Than_Or_Equal_Operator => 1365, + Iir_Kind_Match_Equality_Operator => 1370, + Iir_Kind_Match_Inequality_Operator => 1375, + Iir_Kind_Match_Less_Than_Operator => 1380, + Iir_Kind_Match_Less_Than_Or_Equal_Operator => 1385, + Iir_Kind_Match_Greater_Than_Operator => 1390, + Iir_Kind_Match_Greater_Than_Or_Equal_Operator => 1395, + Iir_Kind_Sll_Operator => 1400, + Iir_Kind_Sla_Operator => 1405, + Iir_Kind_Srl_Operator => 1410, + Iir_Kind_Sra_Operator => 1415, + Iir_Kind_Rol_Operator => 1420, + Iir_Kind_Ror_Operator => 1425, + Iir_Kind_Addition_Operator => 1430, + Iir_Kind_Substraction_Operator => 1435, + Iir_Kind_Concatenation_Operator => 1440, + Iir_Kind_Multiplication_Operator => 1445, + Iir_Kind_Division_Operator => 1450, + Iir_Kind_Modulus_Operator => 1455, + Iir_Kind_Remainder_Operator => 1460, + Iir_Kind_Exponentiation_Operator => 1465, + Iir_Kind_Function_Call => 1473, + Iir_Kind_Aggregate => 1481, + Iir_Kind_Parenthesis_Expression => 1484, + Iir_Kind_Qualified_Expression => 1488, + Iir_Kind_Type_Conversion => 1493, + Iir_Kind_Allocator_By_Expression => 1498, + Iir_Kind_Allocator_By_Subtype => 1504, + Iir_Kind_Selected_Element => 1512, + Iir_Kind_Dereference => 1517, + Iir_Kind_Implicit_Dereference => 1522, + Iir_Kind_Slice_Name => 1529, + Iir_Kind_Indexed_Name => 1535, + Iir_Kind_Psl_Prev => 1541, + Iir_Kind_Psl_Stable => 1546, + Iir_Kind_Psl_Rose => 1551, + Iir_Kind_Psl_Fell => 1556, + Iir_Kind_Psl_Onehot => 1559, + Iir_Kind_Psl_Onehot0 => 1562, + Iir_Kind_Psl_Expression => 1564, + Iir_Kind_Sensitized_Process_Statement => 1586, + Iir_Kind_Process_Statement => 1607, + Iir_Kind_Concurrent_Simple_Signal_Assignment => 1620, + Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1633, + Iir_Kind_Concurrent_Selected_Signal_Assignment => 1647, + Iir_Kind_Concurrent_Assertion_Statement => 1655, + Iir_Kind_Concurrent_Procedure_Call_Statement => 1662, + Iir_Kind_Concurrent_Break_Statement => 1670, + Iir_Kind_Psl_Assert_Directive => 1684, + Iir_Kind_Psl_Assume_Directive => 1696, + Iir_Kind_Psl_Cover_Directive => 1708, + Iir_Kind_Psl_Restrict_Directive => 1719, + Iir_Kind_Block_Statement => 1733, + Iir_Kind_If_Generate_Statement => 1744, + Iir_Kind_Case_Generate_Statement => 1753, + Iir_Kind_For_Generate_Statement => 1762, + Iir_Kind_Component_Instantiation_Statement => 1773, + Iir_Kind_Psl_Default_Clock => 1776, + Iir_Kind_Generate_Statement_Body => 1787, + Iir_Kind_If_Generate_Else_Clause => 1793, + Iir_Kind_Simple_Simultaneous_Statement => 1800, + Iir_Kind_Simultaneous_Null_Statement => 1804, + Iir_Kind_Simultaneous_Procedural_Statement => 1815, + Iir_Kind_Simultaneous_Case_Statement => 1824, + Iir_Kind_Simultaneous_If_Statement => 1833, + Iir_Kind_Simultaneous_Elsif => 1839, + Iir_Kind_Simple_Signal_Assignment_Statement => 1850, + Iir_Kind_Conditional_Signal_Assignment_Statement => 1861, + Iir_Kind_Selected_Waveform_Assignment_Statement => 1873, + Iir_Kind_Signal_Force_Assignment_Statement => 1883, + Iir_Kind_Signal_Release_Assignment_Statement => 1892, + Iir_Kind_Null_Statement => 1896, + Iir_Kind_Assertion_Statement => 1903, + Iir_Kind_Report_Statement => 1909, + Iir_Kind_Wait_Statement => 1917, + Iir_Kind_Variable_Assignment_Statement => 1924, + Iir_Kind_Conditional_Variable_Assignment_Statement => 1931, + Iir_Kind_Return_Statement => 1937, + Iir_Kind_For_Loop_Statement => 1948, + Iir_Kind_While_Loop_Statement => 1959, + Iir_Kind_Next_Statement => 1966, + Iir_Kind_Exit_Statement => 1973, + Iir_Kind_Case_Statement => 1982, + Iir_Kind_Procedure_Call_Statement => 1988, + Iir_Kind_Break_Statement => 1995, + Iir_Kind_If_Statement => 2005, + Iir_Kind_Suspend_State_Statement => 2009, + Iir_Kind_Elsif => 2015, + Iir_Kind_Character_Literal => 2022, + Iir_Kind_Simple_Name => 2029, + Iir_Kind_Selected_Name => 2037, + Iir_Kind_Operator_Symbol => 2042, + Iir_Kind_Reference_Name => 2047, + Iir_Kind_External_Constant_Name => 2056, + Iir_Kind_External_Signal_Name => 2066, + Iir_Kind_External_Variable_Name => 2076, + Iir_Kind_Selected_By_All_Name => 2082, + Iir_Kind_Parenthesis_Name => 2087, + Iir_Kind_Package_Pathname => 2091, + Iir_Kind_Absolute_Pathname => 2092, + Iir_Kind_Relative_Pathname => 2093, + Iir_Kind_Pathname_Element => 2098, + Iir_Kind_Base_Attribute => 2100, + Iir_Kind_Subtype_Attribute => 2105, + Iir_Kind_Element_Attribute => 2110, + Iir_Kind_Across_Attribute => 2115, + Iir_Kind_Through_Attribute => 2120, + Iir_Kind_Nature_Reference_Attribute => 2124, + Iir_Kind_Left_Type_Attribute => 2129, + Iir_Kind_Right_Type_Attribute => 2134, + Iir_Kind_High_Type_Attribute => 2139, + Iir_Kind_Low_Type_Attribute => 2144, + Iir_Kind_Ascending_Type_Attribute => 2149, + Iir_Kind_Image_Attribute => 2155, + Iir_Kind_Value_Attribute => 2161, + Iir_Kind_Pos_Attribute => 2167, + Iir_Kind_Val_Attribute => 2173, + Iir_Kind_Succ_Attribute => 2179, + Iir_Kind_Pred_Attribute => 2185, + Iir_Kind_Leftof_Attribute => 2191, + Iir_Kind_Rightof_Attribute => 2197, + Iir_Kind_Signal_Slew_Attribute => 2205, + Iir_Kind_Quantity_Slew_Attribute => 2213, + Iir_Kind_Ramp_Attribute => 2221, + Iir_Kind_Zoh_Attribute => 2229, + Iir_Kind_Ltf_Attribute => 2237, + Iir_Kind_Ztf_Attribute => 2247, + Iir_Kind_Dot_Attribute => 2254, + Iir_Kind_Integ_Attribute => 2261, + Iir_Kind_Quantity_Delayed_Attribute => 2269, + Iir_Kind_Above_Attribute => 2277, + Iir_Kind_Delayed_Attribute => 2286, + Iir_Kind_Stable_Attribute => 2295, + Iir_Kind_Quiet_Attribute => 2304, + Iir_Kind_Transaction_Attribute => 2313, + Iir_Kind_Event_Attribute => 2317, + Iir_Kind_Active_Attribute => 2321, + Iir_Kind_Last_Event_Attribute => 2325, + Iir_Kind_Last_Active_Attribute => 2329, + Iir_Kind_Last_Value_Attribute => 2333, + Iir_Kind_Driving_Attribute => 2337, + Iir_Kind_Driving_Value_Attribute => 2341, + Iir_Kind_Behavior_Attribute => 2341, + Iir_Kind_Structure_Attribute => 2341, + Iir_Kind_Simple_Name_Attribute => 2348, + Iir_Kind_Instance_Name_Attribute => 2353, + Iir_Kind_Path_Name_Attribute => 2358, + Iir_Kind_Left_Array_Attribute => 2365, + Iir_Kind_Right_Array_Attribute => 2372, + Iir_Kind_High_Array_Attribute => 2379, + Iir_Kind_Low_Array_Attribute => 2386, + Iir_Kind_Length_Array_Attribute => 2393, + Iir_Kind_Ascending_Array_Attribute => 2400, + Iir_Kind_Range_Array_Attribute => 2407, + Iir_Kind_Reverse_Range_Array_Attribute => 2414, + Iir_Kind_Attribute_Name => 2423 ); function Get_Fields_First (K : Iir_Kind) return Fields_Index is @@ -6286,6 +6293,8 @@ package body Vhdl.Nodes_Meta is return Get_Interface_Declaration_Chain (N); when Field_Default_Subprogram => return Get_Default_Subprogram (N); + when Field_Associated_Subprogram => + return Get_Associated_Subprogram (N); when Field_Subprogram_Specification => return Get_Subprogram_Specification (N); when Field_Sequential_Statement_Chain => @@ -6752,6 +6761,8 @@ package body Vhdl.Nodes_Meta is Set_Interface_Declaration_Chain (N, V); when Field_Default_Subprogram => Set_Default_Subprogram (N, V); + when Field_Associated_Subprogram => + Set_Associated_Subprogram (N, V); when Field_Subprogram_Specification => Set_Subprogram_Specification (N, V); when Field_Sequential_Statement_Chain => @@ -9209,6 +9220,17 @@ package body Vhdl.Nodes_Meta is end case; end Has_Default_Subprogram; + function Has_Associated_Subprogram (K : Iir_Kind) return Boolean is + begin + case K is + when Iir_Kind_Interface_Function_Declaration + | Iir_Kind_Interface_Procedure_Declaration => + return True; + when others => + return False; + end case; + end Has_Associated_Subprogram; + function Has_Subprogram_Specification (K : Iir_Kind) return Boolean is begin case K is diff --git a/src/vhdl/vhdl-nodes_meta.ads b/src/vhdl/vhdl-nodes_meta.ads index 9d18dcb2d..3092597a7 100644 --- a/src/vhdl/vhdl-nodes_meta.ads +++ b/src/vhdl/vhdl-nodes_meta.ads @@ -172,6 +172,7 @@ package Vhdl.Nodes_Meta is Field_Base_Name, Field_Interface_Declaration_Chain, Field_Default_Subprogram, + Field_Associated_Subprogram, Field_Subprogram_Specification, Field_Sequential_Statement_Chain, Field_Simultaneous_Statement_Chain, @@ -767,6 +768,7 @@ package Vhdl.Nodes_Meta is function Has_Base_Name (K : Iir_Kind) return Boolean; function Has_Interface_Declaration_Chain (K : Iir_Kind) return Boolean; function Has_Default_Subprogram (K : Iir_Kind) return Boolean; + function Has_Associated_Subprogram (K : Iir_Kind) return Boolean; function Has_Subprogram_Specification (K : Iir_Kind) return Boolean; function Has_Sequential_Statement_Chain (K : Iir_Kind) return Boolean; function Has_Simultaneous_Statement_Chain (K : Iir_Kind) return Boolean; diff --git a/src/vhdl/vhdl-sem_assocs.adb b/src/vhdl/vhdl-sem_assocs.adb index 3bf51c400..a28ebe12e 100644 --- a/src/vhdl/vhdl-sem_assocs.adb +++ b/src/vhdl/vhdl-sem_assocs.adb @@ -2468,7 +2468,8 @@ package body Vhdl.Sem_Assocs is Warn_Hide_Enabled := Is_Warning_Enabled (Warnid_Hide); Enable_Warning (Warnid_Hide, False); - Sem_Scopes.Add_Declarations_From_Interface_Chain (Interface_Chain); + Sem_Scopes.Add_Declarations_From_Interface_Chain + (Interface_Chain, False); Enable_Warning (Warnid_Hide, Warn_Hide_Enabled); diff --git a/src/vhdl/vhdl-sem_inst.adb b/src/vhdl/vhdl-sem_inst.adb index d8f2728ab..4c250d2f4 100644 --- a/src/vhdl/vhdl-sem_inst.adb +++ b/src/vhdl/vhdl-sem_inst.adb @@ -1026,6 +1026,9 @@ package body Vhdl.Sem_Inst is Get_Named_Entity (Get_Actual (Assoc)); begin Set_Instance (Get_Origin (Assoc_Formal), Actual_Subprg); + -- Also set the associated subprogram to the interface + -- subprogram, so that it can referenced through its name. + Set_Associated_Subprogram (Assoc_Formal, Actual_Subprg); end; end if; when others => diff --git a/src/vhdl/vhdl-sem_scopes.adb b/src/vhdl/vhdl-sem_scopes.adb index fd690f364..fcc2707fa 100644 --- a/src/vhdl/vhdl-sem_scopes.adb +++ b/src/vhdl/vhdl-sem_scopes.adb @@ -1007,8 +1007,7 @@ package body Vhdl.Sem_Scopes is Set_Visible_Flag (Decl, True); end Name_Visible; - procedure Iterator_Decl (Decl : Iir; Arg : Arg_Type) - is + procedure Iterator_Decl (Decl : Iir; Arg : Arg_Type) is begin case Get_Kind (Decl) is when Iir_Kind_Subtype_Declaration @@ -1229,23 +1228,57 @@ package body Vhdl.Sem_Scopes is procedure Add_Declarations_List is new Iterator_Decl_List (Arg_Type => Boolean, Handle_Decl => Add_Declaration); - procedure Add_Declarations_From_Interface_Chain (Chain : Iir) + procedure Add_Declarations_From_Interface_Chain + (Chain : Iir; Potentially : Boolean) is - El : Iir; + Inter : Iir; + Assoc : Iir; Id : Name_Id; begin - El := Chain; - while El /= Null_Iir loop - Id := Get_Identifier (El); + Inter := Chain; + while Inter /= Null_Iir loop + Id := Get_Identifier (Inter); -- The chain may be from an implicitely declared subprograms, with -- anonymous identifiers. In that case, all interfaces are -- anonymous and there is no need to iterate. exit when Id = Null_Identifier; - Add_Declaration (El, False); + -- Not very different from Add_Declaration, except for interface + -- subprograms. + case Iir_Kinds_Interface_Declaration (Get_Kind (Inter)) is + when Iir_Kinds_Interface_Object_Declaration + | Iir_Kind_Interface_Package_Declaration + | Iir_Kind_Interface_Terminal_Declaration => + Add_Name (Inter, Id, Potentially); + when Iir_Kinds_Interface_Subprogram_Declaration => + if Potentially then + -- The normal case: an interface subprogram in a package + -- is visible through a use clause. But in fact it refer + -- to the associated subprogram. + Assoc := Get_Associated_Subprogram (Inter); + pragma Assert (Assoc /= Null_Iir); + Add_Name (Assoc, Id, Potentially); + else + -- Called only when resolving associations (the identifiers + -- of the interfaces are put in the name table). + -- TODO: add a flag or create a different procedure ? + Add_Name (Inter, Id, Potentially); + end if; + when Iir_Kind_Interface_Type_Declaration => + Add_Name (Inter, Id, Potentially); + declare + El : Iir; + begin + El := Get_Interface_Type_Subprograms (Inter); + while El /= Null_Iir loop + Add_Name (El, Get_Identifier (El), Potentially); + El := Get_Chain (El); + end loop; + end; + end case; - El := Get_Chain (El); + Inter := Get_Chain (Inter); end loop; end Add_Declarations_From_Interface_Chain; @@ -1278,8 +1311,10 @@ package body Vhdl.Sem_Scopes is -- Temporarly disable hide warning to avoid spurious messages. Enable_Warning (Warnid_Hide, False); - Add_Declarations_From_Interface_Chain (Get_Generic_Chain (Entity)); - Add_Declarations_From_Interface_Chain (Get_Port_Chain (Entity)); + Add_Declarations_From_Interface_Chain + (Get_Generic_Chain (Entity), False); + Add_Declarations_From_Interface_Chain + (Get_Port_Chain (Entity), False); Add_Declarations (Get_Declaration_Chain (Entity), False); Add_Declarations_Of_Concurrent_Statement (Entity); @@ -1314,7 +1349,8 @@ package body Vhdl.Sem_Scopes is -- LRM08 4.9 Package instantiation declarations -- The package instantiation declaration is equivalent to declaration of -- a generic-mapped package, consisting of a package declaration [...] - Add_Declarations (Get_Generic_Chain (Decl), Potentially); + Add_Declarations_From_Interface_Chain + (Get_Generic_Chain (Decl), Potentially); Add_Declarations (Get_Declaration_Chain (Decl), Potentially); end Add_Package_Instantiation_Declarations; @@ -1325,11 +1361,13 @@ package body Vhdl.Sem_Scopes is Add_Package_Declarations (Decl, False); end Add_Package_Declarations; - procedure Add_Component_Declarations (Component: Iir_Component_Declaration) - is + procedure Add_Component_Declarations + (Component: Iir_Component_Declaration) is begin - Add_Declarations_From_Interface_Chain (Get_Generic_Chain (Component)); - Add_Declarations_From_Interface_Chain (Get_Port_Chain (Component)); + Add_Declarations_From_Interface_Chain + (Get_Generic_Chain (Component), False); + Add_Declarations_From_Interface_Chain + (Get_Port_Chain (Component), False); end Add_Component_Declarations; procedure Add_Protected_Type_Declarations diff --git a/src/vhdl/vhdl-sem_scopes.ads b/src/vhdl/vhdl-sem_scopes.ads index b20e224b0..4622ee1a5 100644 --- a/src/vhdl/vhdl-sem_scopes.ads +++ b/src/vhdl/vhdl-sem_scopes.ads @@ -161,7 +161,8 @@ package Vhdl.Sem_Scopes is -- Add declarations of interface chain CHAIN into the current -- declarative region. - procedure Add_Declarations_From_Interface_Chain (Chain : Iir); + procedure Add_Declarations_From_Interface_Chain + (Chain : Iir; Potentially : Boolean); -- Add all declarations for concurrent statements declared in PARENT. procedure Add_Declarations_Of_Concurrent_Statement (Parent : Iir); diff --git a/src/vhdl/vhdl-sem_stmts.adb b/src/vhdl/vhdl-sem_stmts.adb index c06c3e097..ad0a4bccc 100644 --- a/src/vhdl/vhdl-sem_stmts.adb +++ b/src/vhdl/vhdl-sem_stmts.adb @@ -2099,8 +2099,8 @@ package body Vhdl.Sem_Stmts is -- ... and reopen-it. Open_Declarative_Region; Set_Is_Within_Flag (Stmt, True); - Add_Declarations_From_Interface_Chain (Generic_Chain); - Add_Declarations_From_Interface_Chain (Port_Chain); + Add_Declarations_From_Interface_Chain (Generic_Chain, False); + Add_Declarations_From_Interface_Chain (Port_Chain, False); end if; -- LRM93 9.1 diff --git a/testsuite/gna/issue2250/ent.vhdl b/testsuite/gna/issue2250/ent.vhdl new file mode 100644 index 000000000..c640e4b3a --- /dev/null +++ b/testsuite/gna/issue2250/ent.vhdl @@ -0,0 +1,44 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +package test_pkg is + generic (type t_element; + function to_string_element(element : t_element) return string + ); +end package; + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity test is +end entity test; +architecture beh of test is + type t_record is record + address : std_logic_vector(7 downto 0); + data : std_logic_vector(7 downto 0); + end record t_record; + + function record_to_string( + constant rec_data : t_record + ) return string is + begin + return "address: " & to_string(rec_data.address) & ", data: " & to_string(rec_data.data); + end function record_to_string; + + package record_pkg is new work.test_pkg + generic map (t_element => t_record, + to_string_element => record_to_string); + + use record_pkg.all; + +begin + process + variable v_input : t_record := (x"AA", x"BB"); + begin + report "Val is " & to_string_element(v_input) severity note; + wait; + end process; + +end architecture beh; diff --git a/testsuite/gna/issue2250/testsuite.sh b/testsuite/gna/issue2250/testsuite.sh new file mode 100755 index 000000000..e9f2d6113 --- /dev/null +++ b/testsuite/gna/issue2250/testsuite.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +. ../../testenv.sh + +export GHDL_STD_FLAGS=--std=08 +analyze ent.vhdl +elab_simulate test + +clean + +echo "Test successful" |