From 8521efde4b3e3f4ef082608fbd0e4f34d7c38eb6 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Fri, 9 Nov 2018 03:50:10 +0100 Subject: sem_expr: fix reference issue to subtypes. --- src/vhdl/sem_expr.adb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/vhdl/sem_expr.adb b/src/vhdl/sem_expr.adb index 3ea703f38..e08fc5940 100644 --- a/src/vhdl/sem_expr.adb +++ b/src/vhdl/sem_expr.adb @@ -4825,7 +4825,13 @@ package body Sem_Expr is if Expr = Null_Iir then return; end if; - Expr_Type := Get_Type (Expr); + + -- Use the base type; EXPR may define its own subtype (like in + -- qualified expression with forwarding) which must not be referenced + -- above it. In any case, that also makes sense: we need to deal with + -- types, not with subtypes. + Expr_Type := Get_Base_Type (Get_Type (Expr)); + pragma Assert (Expr_Type /= Null_Iir); Result_Type := Compatible_Types_Intersect (Atype, Expr_Type); if Atype /= Null_Iir and then Is_Overload_List (Atype) then -- cgit v1.2.3