diff options
author | Ondrej Ille <ondrej.ille@gmail.com> | 2021-04-03 00:59:07 +0200 |
---|---|---|
committer | tgingold <tgingold@users.noreply.github.com> | 2021-04-03 15:58:38 +0200 |
commit | 22963c83d3debfba9e945a9a206a13e11fe04939 (patch) | |
tree | 6b5a99fe23b46e86cd86d4023f70a142a881bfc7 | |
parent | a94f02122cf1e3b820dc929d0eb91e48af8c5fab (diff) | |
download | ghdl-22963c83d3debfba9e945a9a206a13e11fe04939.tar.gz ghdl-22963c83d3debfba9e945a9a206a13e11fe04939.tar.bz2 ghdl-22963c83d3debfba9e945a9a206a13e11fe04939.zip |
src: More detailed message on invalid variable locations.
-rw-r--r-- | src/vhdl/vhdl-parse.adb | 58 |
1 files changed, 46 insertions, 12 deletions
diff --git a/src/vhdl/vhdl-parse.adb b/src/vhdl/vhdl-parse.adb index 8c975b604..7bff27c69 100644 --- a/src/vhdl/vhdl-parse.adb +++ b/src/vhdl/vhdl-parse.adb @@ -454,6 +454,44 @@ package body Vhdl.Parse is Error_Msg_Parse (Get_Prev_Location, "missing "";"" at end of " & Msg); end Error_Missing_Semi_Colon; + procedure Error_Variable_Location (Kind : Iir_Kind) + is + Prefix : constant String := "non-"; + Common : constant String := "shared variable declaration not allowed "; + begin + case Kind is + + -- Non-Shared variables + when Iir_Kind_Entity_Declaration => + Error_Msg_Parse (Prefix & Common & "in entity declaration"); + when Iir_Kind_Architecture_Body => + Error_Msg_Parse (Prefix & Common & "in architecture body"); + when Iir_Kind_Block_Statement => + Error_Msg_Parse (Prefix & Common & "in block statement"); + when Iir_Kind_Generate_Statement_Body => + Error_Msg_Parse (Prefix & Common & "in generate statement body"); + when Iir_Kind_Package_Declaration => + Error_Msg_Parse (Prefix & Common & "in package declaration"); + when Iir_Kind_Package_Body => + Error_Msg_Parse (Prefix & Common & "in entity body"); + when Iir_Kind_Protected_Type_Declaration => + Error_Msg_Parse (Prefix & Common & "in protected type declaration"); + + -- Shared variables + when Iir_Kind_Function_Body => + Error_Msg_Parse (Common & "in function body"); + when Iir_Kinds_Process_Statement => + Error_Msg_Parse (Common & "in process statement"); + when Iir_Kind_Protected_Type_Body => + Error_Msg_Parse (Common & "in protected type body"); + when Iir_Kind_Simultaneous_Procedural_Statement => + Error_Msg_Parse (Common & "in procedural statement"); + + when others => + Error_Msg_Parse (Prefix & Common & "here"); + end case; + end Error_Variable_Location; + -- Expect and scan ';' emit an error message using MSG if not present. procedure Scan_Semi_Colon (Msg : String) is begin @@ -5267,16 +5305,13 @@ package body Vhdl.Parse is -- shared data. case Get_Kind (Package_Parent) is when Iir_Kind_Entity_Declaration - | Iir_Kind_Architecture_Body - | Iir_Kind_Block_Statement - | Iir_Kind_Generate_Statement_Body - | Iir_Kind_Package_Declaration - | Iir_Kind_Package_Body - | Iir_Kind_Protected_Type_Declaration => - -- FIXME: replace HERE with the kind of declaration - -- ie: "not allowed in a package" rather than "here". - Error_Msg_Parse - ("non-shared variable declaration not allowed here"); + | Iir_Kind_Architecture_Body + | Iir_Kind_Block_Statement + | Iir_Kind_Generate_Statement_Body + | Iir_Kind_Package_Declaration + | Iir_Kind_Package_Body + | Iir_Kind_Protected_Type_Declaration => + Error_Variable_Location(Get_Kind(Package_Parent)); when Iir_Kind_Function_Body | Iir_Kind_Procedure_Body | Iir_Kinds_Process_Statement @@ -5326,8 +5361,7 @@ package body Vhdl.Parse is | Iir_Kinds_Process_Statement | Iir_Kind_Protected_Type_Body | Iir_Kind_Simultaneous_Procedural_Statement => - Error_Msg_Parse - ("shared variable declaration not allowed here"); + Error_Variable_Location(Get_Kind(Package_Parent)); when others => Error_Kind ("parse_declarative_part(3)", Package_Parent); end case; |