aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-04-27 06:53:42 +0200
committerTristan Gingold <tgingold@free.fr>2020-04-27 06:53:42 +0200
commit8cf995880c3ccae87526aadb52799f17053b3521 (patch)
tree1758eb3464c210716cb8ceeaa4b7ace9f4a796a3 /src
parent0d25d53d3c0983046b1348f154b0a86272bf3aeb (diff)
downloadghdl-8cf995880c3ccae87526aadb52799f17053b3521.tar.gz
ghdl-8cf995880c3ccae87526aadb52799f17053b3521.tar.bz2
ghdl-8cf995880c3ccae87526aadb52799f17053b3521.zip
synth-expr: fix handling of array attributes. Fix #1266
Diffstat (limited to 'src')
-rw-r--r--src/synth/synth-expr.adb21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb
index 00c69cb13..5eca7d125 100644
--- a/src/synth/synth-expr.adb
+++ b/src/synth/synth-expr.adb
@@ -2058,10 +2058,27 @@ package body Synth.Expr is
end Synth_Expression_With_Type;
function Synth_Expression (Syn_Inst : Synth_Instance_Acc; Expr : Node)
- return Valtyp is
+ return Valtyp
+ is
+ Etype : Node;
begin
+ Etype := Get_Type (Expr);
+
+ case Get_Kind (Expr) is
+ when Iir_Kind_High_Array_Attribute
+ | Iir_Kind_Low_Array_Attribute
+ | Iir_Kind_Integer_Literal =>
+ -- The type of this attribute is the type of the index, which is
+ -- not synthesized as atype (only as an index).
+ -- For integer_literal, the type is not really needed, and it
+ -- may be created by static evaluation of an array attribute.
+ Etype := Get_Base_Type (Etype);
+ when others =>
+ null;
+ end case;
+
return Synth_Expression_With_Type
- (Syn_Inst, Expr, Get_Subtype_Object (Syn_Inst, Get_Type (Expr)));
+ (Syn_Inst, Expr, Get_Subtype_Object (Syn_Inst, Etype));
end Synth_Expression;
function Synth_Expression_With_Basetype