diff options
author | Tristan Gingold <tgingold@free.fr> | 2018-09-22 13:51:46 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2018-09-22 13:51:46 +0200 |
commit | 5fb9fbc5a3244ea45db141e59cdccb9a3e000fdc (patch) | |
tree | a49f566bf5d4fa884982cbf5c2c77b374c3f1a70 /src | |
parent | 2ee2550e1271f35e4ab7effb453252bcb7aa900f (diff) | |
download | ghdl-5fb9fbc5a3244ea45db141e59cdccb9a3e000fdc.tar.gz ghdl-5fb9fbc5a3244ea45db141e59cdccb9a3e000fdc.tar.bz2 ghdl-5fb9fbc5a3244ea45db141e59cdccb9a3e000fdc.zip |
Add Warnid_Static, detect incorrect use of others in aggregate.
Diffstat (limited to 'src')
-rw-r--r-- | src/vhdl/errorout.ads | 5 | ||||
-rw-r--r-- | src/vhdl/sem_expr.adb | 12 | ||||
-rw-r--r-- | src/vhdl/sem_expr.ads | 3 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap7.adb | 6 |
4 files changed, 22 insertions, 4 deletions
diff --git a/src/vhdl/errorout.ads b/src/vhdl/errorout.ads index 4a3b6fdf7..f512b0624 100644 --- a/src/vhdl/errorout.ads +++ b/src/vhdl/errorout.ads @@ -113,6 +113,9 @@ package Errorout is -- Violation of pure rules. Warnid_Pure, + -- Violation of staticness rules + Warnid_Static, + -- Any error Msgid_Error, @@ -121,7 +124,7 @@ package Errorout is -- All specific warning messages. subtype Msgid_Warnings is Msgid_Type - range Warnid_Library .. Warnid_Pure; + range Warnid_Library .. Warnid_Static; -- Get the image of a warning. This correspond the the identifier of ID, -- in lower case, without the Msgid_Warn_ prefix and with '_' replaced diff --git a/src/vhdl/sem_expr.adb b/src/vhdl/sem_expr.adb index 1fc98c592..605530067 100644 --- a/src/vhdl/sem_expr.adb +++ b/src/vhdl/sem_expr.adb @@ -2597,6 +2597,18 @@ package body Sem_Expr is end if; end; + -- LRM93 7.3.2.2 Array aggregates + -- An others choice is locally static if the applicable index constraint + -- if locally static. + if Info.Nbr_Choices > 0 + and then Info.Others_Choice /= Null_Iir + and then Get_Type_Staticness (Choice_Type) /= Locally + then + Warning_Msg_Sem + (Warnid_Static, +Info.Others_Choice, + "'others' choice allowed only if the index constraint is static"); + end if; + if Reorder_Choices then declare Ngroups : Int32; diff --git a/src/vhdl/sem_expr.ads b/src/vhdl/sem_expr.ads index 5c976ac72..15ae1da39 100644 --- a/src/vhdl/sem_expr.ads +++ b/src/vhdl/sem_expr.ads @@ -156,7 +156,8 @@ package Sem_Expr is Annex_Arr : Annex_Array_Acc; end record; - -- Compute the number of locally static choices and set Has_Others. + -- Compute the number of locally static choices (excluding others) and + -- set Has_Others. procedure Count_Choices (Info : out Choice_Info_Type; Choice_Chain : Iir); -- Allocate and fill INFO.ARR. diff --git a/src/vhdl/translate/trans-chap7.adb b/src/vhdl/translate/trans-chap7.adb index 2351f77bf..582b3be68 100644 --- a/src/vhdl/translate/trans-chap7.adb +++ b/src/vhdl/translate/trans-chap7.adb @@ -2929,6 +2929,8 @@ package body Trans.Chap7 is Expr_Type : Iir; Final : Boolean; + -- Assign EXPR to current position (defined by index VAR_INDEX), and + -- update VAR_INDEX. Handles sub-aggregates. procedure Do_Assign (Expr : Iir) is begin if Final then @@ -3013,8 +3015,8 @@ package body Trans.Chap7 is -- There is only one choice case Get_Kind (El) is when Iir_Kind_Choice_By_Others => - -- falltrough... - null; + -- Handled by positional. + raise Internal_Error; when Iir_Kind_Choice_By_Expression => Do_Assign (Get_Associated_Expr (El)); return; |