aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/vhdl-sem_expr.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2021-03-30 19:43:03 +0200
committerTristan Gingold <tgingold@free.fr>2021-03-30 19:43:03 +0200
commita3292a72683b77c8b0054ffd836c029648a89c55 (patch)
tree9fe67379b6da8d1ca3542dff4caf342f4e720777 /src/vhdl/vhdl-sem_expr.adb
parentef9cb64c5d334a3f0060d8245c8b77fb7daad62d (diff)
downloadghdl-a3292a72683b77c8b0054ffd836c029648a89c55.tar.gz
ghdl-a3292a72683b77c8b0054ffd836c029648a89c55.tar.bz2
ghdl-a3292a72683b77c8b0054ffd836c029648a89c55.zip
vhdl-sem_expr.adb: detect incorrect static aggregate length mismatch. For #1697
Diffstat (limited to 'src/vhdl/vhdl-sem_expr.adb')
-rw-r--r--src/vhdl/vhdl-sem_expr.adb10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/vhdl/vhdl-sem_expr.adb b/src/vhdl/vhdl-sem_expr.adb
index 854da50d8..e8ba7dea6 100644
--- a/src/vhdl/vhdl-sem_expr.adb
+++ b/src/vhdl/vhdl-sem_expr.adb
@@ -2804,6 +2804,10 @@ package body Vhdl.Sem_Expr is
-- True if others choice is present.
Has_Others : Boolean;
+ -- True if one association doesn't have the element_type flag (ie the
+ -- expression is of the same type as an aggregate).
+ Has_Array : Boolean;
+
Has_Error : Boolean;
Pos_Max : Int64;
@@ -2935,10 +2939,14 @@ package body Vhdl.Sem_Expr is
Nbr_Named := 0;
Has_Others := False;
Has_Error := False;
+ Has_Array := False;
Staticness := Locally;
El := Choice_Chain;
Prev_El := Null_Iir;
while El /= Null_Iir loop
+ if not Get_Element_Type_Flag (El) then
+ Has_Array := True;
+ end if;
case Get_Kind (El) is
when Iir_Kind_Choice_By_None =>
Nbr_Pos := Nbr_Pos + 1;
@@ -3001,7 +3009,7 @@ package body Vhdl.Sem_Expr is
if (not Has_Others and not Is_Sub_Range)
and then Nbr_Pos < Pos_Max
-- For aggregates, a positional association can be a vector.
- and then (Vhdl_Std < Vhdl_08 or Is_Case_Stmt)
+ and then (Vhdl_Std < Vhdl_08 or Is_Case_Stmt or not Has_Array)
then
Error_Msg_Sem (+Loc, "not enough elements associated");
elsif Nbr_Pos > Pos_Max then