diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-06-09 07:51:42 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-06-09 18:31:59 +0200 |
commit | 640a95e42afd5ad5709624291be42cb5453332e8 (patch) | |
tree | 4bcc575c70b089e8042b07f9f00b0bde098c4b17 /src | |
parent | 1ac7c2afafbd21879c0074aabeeecfe2d9eb3dfa (diff) | |
download | ghdl-640a95e42afd5ad5709624291be42cb5453332e8.tar.gz ghdl-640a95e42afd5ad5709624291be42cb5453332e8.tar.bz2 ghdl-640a95e42afd5ad5709624291be42cb5453332e8.zip |
vhdl: handle aggregates in choices. Fix #1360
Diffstat (limited to 'src')
-rw-r--r-- | src/vhdl/vhdl-evaluation.ads | 3 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_expr.adb | 7 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/vhdl/vhdl-evaluation.ads b/src/vhdl/vhdl-evaluation.ads index 3b68e003d..1abd5aab6 100644 --- a/src/vhdl/vhdl-evaluation.ads +++ b/src/vhdl/vhdl-evaluation.ads @@ -191,6 +191,9 @@ package Vhdl.Evaluation is -- using the same format as SIMPLE_NAME attribute. function Eval_Simple_Name (Id : Name_Id) return String; + -- Convert aggregate or string literal to a simple agggregate. + function Eval_String_Literal (Str : Iir) return Iir; + -- Compare two string literals (of same length). type Compare_Type is (Compare_Lt, Compare_Eq, Compare_Gt); function Compare_String_Literals (L, R : Iir) return Compare_Type; diff --git a/src/vhdl/vhdl-sem_expr.adb b/src/vhdl/vhdl-sem_expr.adb index 4294e71c2..a801afdbe 100644 --- a/src/vhdl/vhdl-sem_expr.adb +++ b/src/vhdl/vhdl-sem_expr.adb @@ -2315,6 +2315,13 @@ package body Vhdl.Sem_Expr is return; end if; + -- If the choice is an aggregate (which could be static in vhdl08), + -- transform it into a simple aggregate to ease the comparisons. + if Get_Kind (Expr) = Iir_Kind_Aggregate then + Expr := Eval_String_Literal (Expr); + Set_Choice_Expression (Choice, Expr); + end if; + Choice_Len := Eval_Discrete_Type_Length (Get_String_Type_Bound_Type (Get_Type (Expr))); if Sel_Length = -1 then |