diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-10-22 21:14:22 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-10-23 18:41:50 +0200 |
commit | 0af29d861903a5ed67e001d9bb403fbbae6a258b (patch) | |
tree | e6b7165cb8a2f10e1674639c5e7cf86bdb95178f /src/vhdl | |
parent | 1ba62aa31f39af78202810aead98722b13ec408d (diff) | |
download | ghdl-0af29d861903a5ed67e001d9bb403fbbae6a258b.tar.gz ghdl-0af29d861903a5ed67e001d9bb403fbbae6a258b.tar.bz2 ghdl-0af29d861903a5ed67e001d9bb403fbbae6a258b.zip |
vhdl-sem_decls: make sem_declaration public.
Diffstat (limited to 'src/vhdl')
-rw-r--r-- | src/vhdl/vhdl-parse.adb | 2 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_decls.adb | 19 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_decls.ads | 16 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_specs.adb | 5 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_specs.ads | 3 |
5 files changed, 31 insertions, 14 deletions
diff --git a/src/vhdl/vhdl-parse.adb b/src/vhdl/vhdl-parse.adb index 6801f00fc..a6e24922d 100644 --- a/src/vhdl/vhdl-parse.adb +++ b/src/vhdl/vhdl-parse.adb @@ -9433,6 +9433,7 @@ package body Vhdl.Parse is Error_Msg_Parse ("attribute declaration not allowed here"); end if; + Set_Parent (El, Parent); Chain_Append (First, Last, El); end if; when Tok_Group => @@ -9442,6 +9443,7 @@ package body Vhdl.Parse is Error_Msg_Parse ("group template declaration not allowed here"); end if; + Set_Parent (El, Parent); Chain_Append (First, Last, El); end if; when others => diff --git a/src/vhdl/vhdl-sem_decls.adb b/src/vhdl/vhdl-sem_decls.adb index a8da895eb..b92e56cf4 100644 --- a/src/vhdl/vhdl-sem_decls.adb +++ b/src/vhdl/vhdl-sem_decls.adb @@ -850,7 +850,7 @@ package body Vhdl.Sem_Decls is -- LAST_DECL is set only if DECL is part of a list of declarations (they -- share the same type and the same default value). - procedure Sem_Object_Declaration (Decl: Iir; Parent : Iir; Last_Decl : Iir) + procedure Sem_Object_Declaration (Decl: Iir; Last_Decl : Iir) is Deferred_Const : constant Iir := Get_Deferred_Constant (Decl); Atype: Iir; @@ -969,7 +969,8 @@ package body Vhdl.Sem_Decls is else Set_Deferred_Declaration_Flag (Decl, True); end if; - if Get_Kind (Parent) /= Iir_Kind_Package_Declaration then + if Get_Kind (Get_Parent (Decl)) /= Iir_Kind_Package_Declaration + then Error_Msg_Sem (+Decl, "a constant must have a default value"); end if; @@ -1019,6 +1020,7 @@ package body Vhdl.Sem_Decls is -- parse. if Flags.Vhdl_Std >= Vhdl_00 then declare + Parent : constant Iir := Get_Parent (Decl); Base_Type : constant Iir := Get_Base_Type (Atype); Is_Protected : constant Boolean := Get_Kind (Base_Type) = Iir_Kind_Protected_Type_Declaration; @@ -1168,10 +1170,9 @@ package body Vhdl.Sem_Decls is -- Note: this check is also performed when a file is referenced. -- But a file can be declared without being explicitly referenced. declare - Parent : Iir; + Parent : constant Iir := Get_Parent (Decl); Spec : Iir; begin - Parent := Get_Parent (Decl); case Get_Kind (Parent) is when Iir_Kind_Function_Body => Spec := Get_Subprogram_Specification (Parent); @@ -2045,14 +2046,12 @@ package body Vhdl.Sem_Decls is -- PREV_DECL is the previous one (used for declaration like -- signal a, b : mytype; ) to get type and default value from the -- previous declaration. - -- PARENT is the parent node (useful ?) -- IS_GLOBAL must be true when the declaration can be used by an external -- file (so for package and entities). -- ATTR_SPEC_CHAIN is the chain of attribute specifications, used to -- handle the 'others' case. procedure Sem_Declaration (Decl : in out Iir; Prev_Decl : in out Iir; - Parent : Iir; Is_Global : Boolean; Attr_Spec_Chain : in out Iir) is begin @@ -2065,13 +2064,13 @@ package body Vhdl.Sem_Decls is when Iir_Kind_Signal_Declaration | Iir_Kind_Constant_Declaration | Iir_Kind_Variable_Declaration => - Sem_Object_Declaration (Decl, Parent, Prev_Decl); + Sem_Object_Declaration (Decl, Prev_Decl); when Iir_Kind_File_Declaration => Sem_File_Declaration (Decl, Prev_Decl); when Iir_Kind_Attribute_Declaration => Sem_Attribute_Declaration (Decl); when Iir_Kind_Attribute_Specification => - Sem_Attribute_Specification (Decl, Parent); + Sem_Attribute_Specification (Decl); if Get_Entity_Name_List (Decl) in Iir_Flists_All_Others then Set_Attribute_Specification_Chain (Decl, Attr_Spec_Chain); Attr_Spec_Chain := Decl; @@ -2150,7 +2149,7 @@ package body Vhdl.Sem_Decls is -- Insert *before* DECL pending implicit signal declarations created -- for DECL after LAST_DECL. This updates LAST_DECL. - Insert_Pending_Implicit_Declarations (Parent, Prev_Decl); + Insert_Pending_Implicit_Declarations (Get_Parent (Decl), Prev_Decl); end Sem_Declaration; procedure Sem_Declaration_Chain (Parent : Iir) @@ -2187,7 +2186,7 @@ package body Vhdl.Sem_Decls is while Decl /= Null_Iir loop - Sem_Declaration (Decl, Last_Decl, Parent, Is_Global, Attr_Spec_Chain); + Sem_Declaration (Decl, Last_Decl, Is_Global, Attr_Spec_Chain); if Last_Decl = Null_Iir then -- Append now to handle expand names. diff --git a/src/vhdl/vhdl-sem_decls.ads b/src/vhdl/vhdl-sem_decls.ads index 3ab43adf8..744a586a6 100644 --- a/src/vhdl/vhdl-sem_decls.ads +++ b/src/vhdl/vhdl-sem_decls.ads @@ -22,6 +22,22 @@ package Vhdl.Sem_Decls is procedure Sem_Interface_Chain (Interface_Chain: Iir; Interface_Kind : Interface_Kind_Type); + -- Analyze declaration DECL. + -- This is a sub-procedure of Sem_Declaration_Chain used only for + -- PSL verification units. + -- + -- PREV_DECL is the previous one (used for declaration like + -- signal a, b : mytype; ) to get type and default value from the + -- previous declaration. + -- IS_GLOBAL must be true when the declaration can be used by an external + -- file (so for package and entities). + -- ATTR_SPEC_CHAIN is the chain of attribute specifications, used to + -- handle the 'others' case. + procedure Sem_Declaration (Decl : in out Iir; + Prev_Decl : in out Iir; + Is_Global : Boolean; + Attr_Spec_Chain : in out Iir); + -- Analyze declarations of PARENT. procedure Sem_Declaration_Chain (Parent : Iir); diff --git a/src/vhdl/vhdl-sem_specs.adb b/src/vhdl/vhdl-sem_specs.adb index bdefcfbca..77619b3ce 100644 --- a/src/vhdl/vhdl-sem_specs.adb +++ b/src/vhdl/vhdl-sem_specs.adb @@ -707,9 +707,10 @@ package body Vhdl.Sem_Specs is Attribute_A_Decl (Name, Attr, True, True); end Sem_Signature_Entity_Designator; - procedure Sem_Attribute_Specification - (Spec : Iir_Attribute_Specification; Scope : Iir) + procedure Sem_Attribute_Specification (Spec : Iir_Attribute_Specification) is + Scope : constant Iir := Get_Parent (Spec); + -- Emit an error message when NAME is not found. procedure Error_Attribute_Specification (Name : Iir) is diff --git a/src/vhdl/vhdl-sem_specs.ads b/src/vhdl/vhdl-sem_specs.ads index d626a9bfb..b74ce6308 100644 --- a/src/vhdl/vhdl-sem_specs.ads +++ b/src/vhdl/vhdl-sem_specs.ads @@ -31,8 +31,7 @@ package Vhdl.Sem_Specs is function Get_Entity_Class_Kind (Decl : Iir) return Vhdl.Tokens.Token_Type; - procedure Sem_Attribute_Specification - (Spec : Iir_Attribute_Specification; Scope : Iir); + procedure Sem_Attribute_Specification (Spec : Iir_Attribute_Specification); -- Check declarations following an ALL/OTHERS attribute specification. -- ATTR_SPEC_CHAIN is the linked list of all attribute specifications whith |